title: ENOENT: no such file or directory readFileSync
body: <p>I'm trying to pass a json file path to an ebay auth function to gain a token.
  This works locally by stating the file name alone. However, as I have my next js app deployed as Node in Vercel, I need to call readFileSync to ensure the json file is included in the build.</p>
  <p>To do that i've implemented: -</p>
  <pre><code>const { readFileSync } = require(&quot;fs&quot;);
    var path = require(&quot;path&quot;);
  
    const file = readFileSync(
      path.join(__dirname, &quot;config/eBayJson.json&quot;),
      &quot;utf8&quot;
    );
  </code></pre>
  <p>in my getServerSideProps.</p>
  <p>However, although my file is clearly at the right path, and I'm calling __dirname to ensure I have the right path. I'm still getting errors, now locally and in the vercel deployment that the file or directory does not exist: -</p>
  <pre><code>Error: ENOENT: no such file or directory, open '\config\eBayJson.json'
      at Object.openSync (node:fs:490:3)
      at readFileSync (node:fs:391:35)
      at getServerSideProps (D:\Web\StoreApp\nextjs-store\.next\server\pages\inventory.js:3846:16)
      at renderToHTML (D:\Web\StoreApp\nextjs-store\node_modules\next\dist\next-server\server\render.js:40:221)        
      at async D:\Web\StoreApp\nextjs-store\node_modules\next\dist\next-server\server\next-server.js:112:97
      at async D:\Web\StoreApp\nextjs-store\node_modules\next\dist\next-server\server\next-server.js:105:142
      at async DevServer.renderToHTMLWithComponents (D:\Web\StoreApp\nextjs-store\node_modules\next\dist\next-server\server\next-server.js:137:387)
      at async DevServer.renderToHTML (D:\Web\StoreApp\nextjs-store\node_modules\next\dist\next-server\server\next-server.js:138:522)
      at async DevServer.renderToHTML (D:\Web\StoreApp\nextjs-store\node_modules\next\dist\server\next-dev-server.js:35:578)
      at async DevServer.render (D:\Web\StoreApp\nextjs-store\node_modules\next\dist\next-server\server\next-server.js:75:236)
      at async Object.fn (D:\Web\StoreApp\nextjs-store\node_modules\next\dist\next-server\server\next-server.js:59:580)    at async Router.execute (D:\Web\StoreApp\nextjs-store\node_modules\next\dist\next-server\server\router.js:25:67) 
      at async DevServer.run (D:\Web\StoreApp\nextjs-store\node_modules\next\dist\next-server\server\next-server.js:69:1042)
      at async DevServer.handleRequest (D:\Web\StoreApp\nextjs-store\node_modules\next\dist\next-server\server\next-server.js:34:504) {
    errno: -4058,
    syscall: 'open',
    path: '\\config\\eBayJson.json'
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/g8HXt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g8HXt.png" alt="enter image description here" /></a></p>
  <p>I'm at a loss for what I'm doing wrong. Most of the stack overflow answers I could find were about the lack of __dirname which I've already included.</p>
  <p>Any help much appreciated!</p>