“Error deploying Node app on render.com: ‘The engine ‘node’ is incompatible with this module'”

huangapple go评论63阅读模式
英文:

Error deploying Node app on render.com: "The engine 'node' is incompatible with this module"

问题

在 render.com 上部署 Node 应用时出现错误: "引擎 'node' 与此模块不兼容"

我正在尝试在 render.com 上部署我的 Node.js 应用程序,但遇到了以下问题

error mongoose@7.2.2: The engine "node" is incompatible with this module. Expected version ">=14.20.1". Got "14.17.0"

这是我的 package.json 文件:

{
  "dependencies": {
    "cors": "^2.8.5",
    "crypto": "^1.0.1",
    "dotenv": "^16.1.3",
    "express": "^4.18.2",
    "mongoose": "^7.2.2",
    "nodemon": "^2.0.22"
  },
  "name": "shop",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "author": "",
  "license": "ISC",
  "description": ""
}

我正在尝试在 render.com 上部署我的 Node.js 应用程序,但遇到了以下问题

error mongoose@7.2.2: The engine "node" is incompatible with this module. Expected version ">=14.20.1". Got "14.17.0"
英文:

Error deploying Node app on render.com: "The engine 'node' is incompatible with this module"

I am trying to deploy my Node.js application on render.com, but I encountered the following

error mongoose@7.2.2: The engine "node" is incompatible with this module. Expected version ">=14.20.1". Got "14.17.0"

Here is my package.json file:

{
  "dependencies": {
    "cors": "^2.8.5",
    "crypto": "^1.0.1",
    "dotenv": "^16.1.3",
    "express": "^4.18.2",
    "mongoose": "^7.2.2",
    "nodemon": "^2.0.22"
  },
  "name": "shop",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "author": "",
  "license": "ISC",
  "description": ""
}

I am trying to deploy my Node.js application on render.com, but I encountered the following

error mongoose@7.2.2: The engine "node" is incompatible with this module. Expected version ">=14.20.1". Got "14.17.0"

答案1

得分: 3

为了解决这个问题,您可以通过在您的 package.json 文件中添加 "engines" 字段并指定所需的 Node.js 版本来解决。这是您需要做的:

"engines": {
  "node": ">=14.20.1"
}

在我的情况下:

{
  "dependencies": {
    "cors": "^2.8.5",
    "crypto": "^1.0.1",
    "dotenv": "^16.1.3",
    "express": "^4.18.2",
    "mongoose": "^7.2.2",
    "nodemon": "^2.0.22"
  },
  "name": "shop",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "engines": {
    "node": ">=14.20.1"
  },
  "author": "",
  "license": "ISC",
  "description": ""
}

这会通知托管平台,您的应用程序需要至少 Node.js 版本 14.20.1 或更高版本才能正常运行。

确保保存对 package.json 文件的更改。如果您正在使用像 Git 这样的版本控制系统,请提交并推送更新后的文件到您的代码库。

通过添加 "engines" 字段并指定所需的 Node.js 版本,托管平台现在应该在部署您的应用程序时使用兼容的版本。这应该解决您遇到的 "The engine 'node' is incompatible with this module" 错误。

英文:

To resolve this issue, you can update your package.json file by adding the "engines" field and specifying the required Node.js version. Here's what you need to do:

"engines": {
  "node": ">=14.20.1"
}

in my case:

{
  "dependencies": {
    "cors": "^2.8.5",
    "crypto": "^1.0.1",
    "dotenv": "^16.1.3",
    "express": "^4.18.2",
    "mongoose": "^7.2.2",
    "nodemon": "^2.0.22"
  },
  "name": "shop",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
 "engines": {
      "node": ">=14.20.1"
    },
  "author": "",
  "license": "ISC",
  "description": ""
}

This informs the hosting platform that your application requires at least Node.js version 14.20.1 or higher to run properly.

Make sure to save the changes to your package.json file. If you're using a version control system like Git, commit and push the updated file to your repository.

By adding the "engines" field and specifying the required Node.js version, the hosting platform should now use a compatible version when deploying your application. This should resolve the "The engine 'node' is incompatible with this module" error you're experiencing.

答案2

得分: 1

add Build Command - 在render.com上使用 yarn --ignore-engines

英文:

add Build Command - yarn --ignore-engines on render.com

https://i.stack.imgur.com/tQDAo.png

huangapple
  • 本文由 发表于 2023年6月5日 01:27:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76401613.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定