【发布时间】:2020-05-04 19:06:22
【问题描述】:
我的 react 应用是用 Gatsby 开发的。依赖“whatwg-fetch”的构建过程失败
我的应用结构基于以下项目。 https://github.com/mongodb-university/stitch-tutorial-todo-web
我在网上找到了一些提示,他们会检查窗口,但我无法让它与我的结构一起使用。 例如:https://www.gitmemory.com/issue/gatsbyjs/gatsby/8612/527732596
错误日志:
1 | var support = {
> 2 | searchParams: 'URLSearchParams' in self,
| ^
3 | iterable: 'Symbol' in self && 'iterator' in Symbol,
4 | blob:
5 | 'FileReader' in self &&
WebpackError: ReferenceError: self is not defined
- fetch.js:2 Module../node_modules/whatwg-fetch/fetch.js
node_modules/whatwg-fetch/fetch.js:2:1
- BrowserFetchTransport.js:1 Module../node_modules/mongodb-stitch-browser-core/dist/esm/core/internal/net/BrowserFetchTransport.js
node_modules/mongodb-stitch-browser-core/dist/esm/core/internal/net/BrowserFetchTransport.js:1:1
- index.js:1 Module../node_modules/mongodb-stitch-browser-core/dist/esm/index.js
node_modules/mongodb-stitch-browser-core/dist/esm/index.js:1:1
- index.js:1 Module../node_modules/mongodb-stitch-browser-sdk/dist/esm/index.js
node_modules/mongodb-stitch-browser-sdk/dist/esm/index.js:1:1`
【问题讨论】:
标签: webpack gatsby mongodb-stitch