I am trying to use dgraph-js-http in a Svelte application.
The initial error I was facing was:
Uncaught ReferenceError: buffer is not defined
<anonymous> http://localhost:5000/build/bundle.js:6947
I'm including this as maybe my solution to this was not the best, and that hopefully there is a way to solve both this issue, and the current blocker issue.
However, after a trial-and-error approach (see below for the various things I've tried) I'm now stuck.
After solving the above error, I am now blocked on this error:
Uncaught ReferenceError: define is not defined
None of the following have worked.
<script src="https://bundle.run/[email protected]"></script>
to index.htmlnpm install stream
import * as Stream from "stream"
to the App.svelte fileimport * as Stream from "stream"
to the stores.js filepreferBuiltins:true
to rollup.config.js
npm install --save-dev rollup-plugin-node-polyfills
preferBuiltins:false
to rollup.config.js
. This resolved prior errors and resulted in the new error of: Uncaught ReferenceError: define is not defined
npm install --save define
. This, now results in the current blocker:Uncaught ReferenceError: exports is not defined
I think you missed type: "module"
attribute in package.json. Here, the type attribute represents whether the type of javascript interpreter is commonjs or babel. type: "module"
indicates that you are going to use babel as the ECMA script interpreter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With