我遇到了一个关于盖茨比云的构建的问题,这让我很困惑,而且我在网上找不到任何信息!
我有一个在本地运行良好的站点构建(例如,在我的笔记本电脑上),但是在Gatsby上运行时,始终会导致以下错误:
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错误的文件和行号始终相同。然而,由于我不是一个web开发人员(这是我自愿参与的社区项目,那里没有专业的web开发人员),我实际上只是在侵入复制和粘贴代码.我在这里撞到了一面墙,不知道该如何度过这段时间。我非常感谢您的帮助。尤其是作为一个预算完全为零的社区项目,我无法在这里使用盖茨比的商业支持!
提前感谢任何人提供的帮助
发布于 2021-07-30 16:19:17
当某些内容在本地构建,但没有在任何服务器环境中(本例中是Netlify或Gatsby )时,通常是由Node环境之间的版本不匹配造成的。在这种情况下,你给了我线索:
I的本地节点版本与在Gatsby上使用的版本不同;16.4.0本地版本对12.22.1版本
这意味着您正在运行不同的依赖版本,在这两个环境中都会导致不同的行为。
在盖茨比的云环境中,您可以将Node version by setting the NODE_VERSION环境变量自定义为16.4.0。这应该能解决你的问题。因为根据文档,它默认为12
NODE_VERSION:指定项目应该使用的Node.js版本。例如,NODE_VERSION=10。默认为12.
https://stackoverflow.com/questions/68581788
复制相似问题