引擎“节点”与此模块不兼容。预期版本“12.x”。得到“14.8.0”

问题描述 投票:0回答:4

我尝试做一个

yarn add
,但我有这个错误:

The engine "node" is incompatible with this module. Expected version "12.x". Got "14.8.0"
node.js reactjs package yarnpkg package.json
4个回答
18
投票

运行这些命令:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

然后在你的项目目录中运行:

rm -r ./node_modules
rm ./yarn.lock

此后,

yarn install | add | upgrade
应该按预期工作。

附注如果您使用

npm
包管理器,而不是
rm ./yarn.lock
运行
rm ./package-lock.json


10
投票

一次性修复“引擎节点与该模块不兼容”问题。

$ yarn install --ignore-engines

9
投票

我可以建议 2 个解决方案:

1/ 它有效,但可能不是最好的方法

您只需更新您的packages.json。

目前:

 "engines": {
     "node": "12.x"
 }

更新了:

 "engines": {
     "node": "14.8.0"
 }

2/我认为这是一种更干净的方式

您可以使用

nvm use x
来使用 Node 版本。

示例:

nvm use 14
使用节点版本 14

也许你必须先跑:

nvm install 14


3
投票

当我尝试使用 React 制作新应用程序时,我遇到了同样的问题。当我这样做时

npx create-react-app my-app
, 我收到此错误:

[电子邮件受保护]:引擎“节点”与此模块不兼容。预期版本“^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0”。得到“14.8.0” 我用这个解决了这个问题,我在其他 stockoverflow 答案中发现了这个问题。 我无法使用 npx create-react-app 安装 React?

npm install -g create-react-app 

这可能对你有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.