【发布时间】:2021-07-31 00:19:17
【问题描述】:
我在 Gatsby Cloud 上的构建遇到了一个问题,这让我很困惑,而且我在网上找不到任何信息!
我的站点构建在本地(即在我的笔记本电脑上)运行良好,但是在 Gatsby Cloud 上运行时始终会导致以下错误:
failed Building static HTML for pages - 0.302s
ERROR Building static HTML failed
5 | };
6 |
> 7 | module.exports["default"] = module.exports, module.exports.__esModule = true;
| ^
8 | return _setPrototypeOf(o, p);
10 |
9 | }
- setPrototypeOf.js:7
[project]/[@babel]/runtime/helpers/setPrototypeOf.js:7:3
WebpackError: /usr/src/app/www/public/render-page.js:4464
- utils.js:267
- utils.js:103
[project]/[@gatsbyjs]/reach-router/lib/utils.js:267:1
[project]/[@gatsbyjs]/reach-router/lib/utils.js:103:1
- utils.js:241
[project]/[@gatsbyjs]/reach-router/es/lib/utils.js:241:4
- history.js:48
[project]/[@gatsbyjs]/reach-router/lib/utils.js:127:1
- utils.js:127
[project]/[@gatsbyjs]/reach-router/es/lib/history.js:52:1
- history.js:52
[project]/[@gatsbyjs]/reach-router/es/lib/history.js:48:1
- extends.js:20
[project]/[@babel]/runtime/helpers/extends.js:20:1
[project]/[@gatsbyjs]/reach-router/lib/utils.js:166:1
- utils.js:166
not finished Caching HTML renderer compilation - 0.381s
not finished Caching JavaScript and CSS webpack compilation - 11.935s
ERROR Failed to compile: Error: Exited with code 1
超过 3 次尝试构建,webpack 错误的文件和行号始终相同。但是,由于我不是网络开发人员(这是我自愿参与的社区项目,没有专业的网络开发人员),而且我真的只是在复制和粘贴代码......我碰壁了在这里,不知道如何克服这一点。我真的很感激任何帮助。特别是作为一个预算为零的社区项目,我无法在这里使用 Gatsby 的商业支持! ????
提前感谢任何人都可以提供的任何帮助
【问题讨论】:
-
它是否在本地构建?你也可以分享你的
gatsby-config.js吗?特别是 webpack 配置部分。 -
感谢费兰的回复。它确实在本地构建和服务完全正常。这是我的
Gatsby-config.js:link -
您是否在云端设置了环境变量?
-
是的,这两个环境变量都是在 Gatsby Cloud 中设置的,其值和名称与在本地构建时使用的相同。在尝试(徒劳地☹️)进一步解决这个问题时,我注意到了 2 件事: 1. 我在本地使用的 Node 版本与在 Gatsby Cloud 上使用的不同;本地 16.4.0 与云端 12.22.1; 2.当我在本地构建时,render-page.js 文件似乎没有被创建......虽然我完全不清楚为什么这是我害怕????请问@fbuireu 这是否有助于缩小范围?
标签: reactjs gatsby react-leaflet gatsby-cloud