title: Sveltekit - 500 process is not defined or exports is not defined
body: <p>I'm trying to call a GRPC service (a dGraph api) from a Sveltekit (<code>SvelteKit v1.0.0-next.114</code>) application.</p>
  <p>I am using a <code>writable</code> store from <code>svelte/store</code>, and am able to log to the console the response from calling the GRPC service.</p>
  <p>However, we I import the store into my svelte component, using the following, I get the below error.</p>
  <pre><code> &lt;script&gt;
      import {resume_store} from '../../stores/resume';
      console.log($resume_store);
   &lt;/script&gt;
  </code></pre>
  <h1>Error</h1>
  <pre><code>500
  
  process is not defined
  
  node_modules/@grpc/grpc-js/build/src/logging.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:9012:28
  __require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
  node_modules/@grpc/grpc-js/build/src/metadata.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:9057:21
  __require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
  node_modules/@grpc/grpc-js/build/src/call-credentials.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:9231:22
  __require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
  node_modules/@grpc/grpc-js/build/src/index.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:15325:30
  __require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
  node_modules/dgraph-js/lib/util.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:15483:16
  __require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
  node_modules/dgraph-js/lib/types.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:15595:18
  __require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
  node_modules/dgraph-js/lib/dgraph.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:17224:15
  __require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
  node_modules/dgraph-js/lib/index.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:17254:18
  __require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
  @http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:17261:25
  </code></pre>
  <h1>Alternative Dqraph client</h1>
  <p>I also tried using <a href="https://github.com/dgraph-io/dgraph-js-http" rel="noreferrer">dgraph-js-http</a> client.</p>
  <p>The observations (see below) were the same - that being, for a brief moment the page looked as expected.</p>
  <p>Firstly, I was getting an error that looked like it was the same as described on <a href="https://github.com/vitejs/vite/issues/2579" rel="noreferrer">https://github.com/vitejs/vite/issues/2579</a>. However, I didnt save this, so cannot paste the exact error here.</p>
  <p>I then tried</p>
  <ol>
  <li>deleting the <code>node_modules</code></li>
  <li>running <code>npm install</code></li>
  <li>running <code>npm dev run</code></li>
  </ol>
  <p>Then, however the following error occurred.</p>
  <h1>Error - Buffer2 is undefined</h1>
  <pre><code>
  500
  
  Buffer2 is undefined
  
  node_modules/safe-buffer/index.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:554:9
  __require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
  node_modules/jws/lib/sign-stream.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:1126:19
  __require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
  node_modules/jws/index.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:1306:22
  __require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
  node_modules/jsonwebtoken/decode.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:1339:15
  __require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
  node_modules/jsonwebtoken/index.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:3396:15
  __require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
  node_modules/dgraph-js-http/lib/clientStub.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:3598:15
  __require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
  node_modules/dgraph-js-http/lib/index.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:4587:18
  __require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
  @http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:4595:30
  </code></pre>
  <p>Other attempts included:</p>
  <ul>
  <li>Adding <code>export const hydrate = false;</code> to the <code>.svelte</code> file, however this made no difference.</li>
  <li>Related to the above point, I tried adding <code>context=&quot;module&quot;</code> to the <code>&lt;script&gt;</code> tag, as this is what is shown in the Sveltekit docs related to hydrate - see <a href="https://kit.svelte.dev/docs#ssr-and-javascript-hydrate" rel="noreferrer">https://kit.svelte.dev/docs#ssr-and-javascript-hydrate</a>. However this resulted in an error of <code>Cannot reference store value inside &lt;script context=&quot;module&quot;&gt;</code></li>
  </ul>
  <h1>Observations</h1>
  <p>For a brief moment the web page of the Sveltekit application does display the result from the dgraph grpc service call - for maybe a second. Then the error message, above, is displayed.</p>