我在 Render.com 上托管时遇到 Node 版本的 Mongoose 错误
状态显示:构建代码时以状态 1 退出。
Jun 15 12:09:54 PM ==> It looks like we don't have access to your repo, but we'll try to clone it anyway.
Jun 15 12:09:54 PM ==> Cloning from https://github.com/yashkolte/New-Instagram...
Jun 15 12:09:56 PM ==> Checking out commit e6b9470786f0cd5ab8d449315eb3201968d9cc4f in branch main
Jun 15 12:10:01 PM ==> Using Node version 14.17.0 (default)
Jun 15 12:10:01 PM ==> Docs on specifying a Node version: https://render.com/docs/node-version
Jun 15 12:10:01 PM ==> Running build command 'yarn'...
Jun 15 12:10:01 PM yarn install v1.22.5
Jun 15 12:10:01 PM info No lockfile found.
Jun 15 12:10:01 PM [1/4] Resolving packages...
Jun 15 12:10:08 PM [2/4] Fetching packages...
Jun 15 12:10:13 PM error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.20.1". Got "14.17.0"
Jun 15 12:10:13 PM error Found incompatible module.
Jun 15 12:10:13 PM info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Jun 15 12:10:13 PM ==> Build failed 😞
如何解决此问题,如果无法解决错误,请给出“渲染”的替代方案。
我在 render.com 上找到了有关指定节点版本的文档
https://render.com/docs/node-version
在 package.json 中添加这些行
"engines": {
"node": ">=14.20.1"
},
然后提交并推送到 git, 在“渲染”上部署最新的提交
问题现已解决
在 package.json 中添加这行代码。
"engines": {
"node": ">=NODE_JS_VERSION"
},
将其添加到您的 package.json
"engines": { "node": ">=14.20.1" }
我也有同样的问题。
我将节点版本更改为 18.17.0,而不是渲染默认版本 14.17.0。
您可以查看本指南以获取更多信息。 https://render.com/docs/node-version