javascript - Svelte: Uncaught ReferenceError: exports is not defined
问题描述
Background
I am trying to use dgraph-js-http in a Svelte application.
Error
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.
Current error
After solving the above error, I am now blocked on this error:
Uncaught ReferenceError: define is not defined
Attempts to resolve
None of the following have worked.
- Add
<script src="https://bundle.run/stream@0.0.2"></script>
to index.html - Run
npm install stream
- Add
import * as Stream from "stream"
to the App.svelte file - Add
import * as Stream from "stream"
to the stores.js file - Add
preferBuiltins:true
torollup.config.js
- Add
npm install --save-dev rollup-plugin-node-polyfills
- Add
preferBuiltins:false
torollup.config.js
. This resolved prior errors and resulted in the new error of:Uncaught ReferenceError: define is not defined
- Add
npm install --save define
. This, now results in the current blocker:
Uncaught ReferenceError: exports is not defined
解决方案
推荐阅读
- google-bigquery - SQL:Google BigQuery 中的日期时间 UTC 和整数转换为日期
- android - 我的片段中的回收站视图导致动画看起来不连贯
- mysql - 根据另一列选择不重复的非重复列
- sql - aws athena 转换数组
> 到餐桌 - python - 通过 object.__getattribute__(type(self), attr) 调用描述符不起作用
- mysql - 一次查询所有数组数据!结果是通过分隔数组的每个 id
- excel - 如何确定我的代码是否成功创建了 oExec 和 nchromePro 对象?
- php - jQuery 没有在 Wordpress 上定义-smoothstate Js
- mysql - 插入数据并用排名填充列
- amazon-web-services - 在 AWS 中,我需要帮助以通过公共 ip 或公共 dns 拒绝 url 并仅允许通过域 (CNAME) 访问