在将代码部署到AWS时,我遇到了以下的yarn错误
error fs-extra@7.0.1: The engine "node" is incompatible with this module. Expected version ">=6 <7 || >=8". Got "7.0.0"
任何想法这将如何解决?如果我在package.json中指定引擎,这是否有效?
{
"engines" : {
"node" : ">=8.0.0"
}
}
在将代码部署到AWS时,我遇到了以下的yarn错误
error fs-extra@7.0.1: The engine "node" is incompatible with this module. Expected version ">=6 <7 || >=8". Got "7.0.0"
任何想法这将如何解决?{
"engines" : {
"node" : ">=8.0.0"
}
}
您可以尝试忽略引擎:
$ yarn install --ignore-engines
或者
$ yarn global add <your app> --ignore-engines
您可以运行以下命令查看所有可忽略的内容:
$ yarn help | grep -- --ignore
--ignore-scripts don't run lifecycle scripts
--ignore-platform ignore platform checks
--ignore-engines ignore engines check
--ignore-optional ignore optional dependencies
yarn config set ignore-engines true
来永久禁用整个系统上的这种侵入性检查,以使其更易于理解。 - Nabil Freeman.nvmrc
文件,该文件指定了每个项目的节点版本。从此页面https://nodejs.org/en/about/releases/选择一个稳定的长期支持(LTS)版本,并确保它与错误信息中的预期版本匹配。请注意,不要改变原文的意思。 - Hartley Brody您需要升级您的 node 版本。
我也遇到了同样的问题。
如果您使用了 Homebrew,请运行:
brew update # This updates Homebrew to latest version
brew upgrade node
nvm current node -v # Checks your current version
nvm install <version> # Example: nvm install 12.14.1
对于上述步骤,请前往Node.js - Downloads。
获取一个满足您错误条件的版本,最新版本应该可以正常工作。
更详细的步骤说明:如何更新Node.js
brew update; brew search node; brew unlink node; brew install node@12
。 - J.Z.brew link node@12
的最后一步骤。 - azizbroExpected version ">=16".
所以我运行了 nvm install 16
. - John Skiles Skinneryarn config set ignore-engines true
但是,如果您想要一个永久的解决方案,则需要执行以下操作:
--ignore-engines
来忽略引擎检查:
yarn add <package_name> --ignore-engines
% yarn install --ignore-engines
版本> 8.0
。% brew upgrade node
% brew install nodenv
% nodenv init
# Load nodenv automatically by appending
# the following to ~/.zshrc:
eval "$(nodenv init -)"
% nodenv install 6.0.0 //or some other version
许多答案建议设置标志以忽略版本错误。
更好的选择是将此用作提醒,更新您的Node版本为最近支持您要安装的包的版本。
nvm install 16.16.0 # download & install locally on your system
nvm use 16.16.0 # update current project's .nvmrc file
.nvmrc
文件,用于指定每个项目所使用的Node.js版本。16.16.0
已经接近生命周期的尾声了! - undefined我用yarn --ignore-engines
解决了我的问题,但我不确定为什么以及如何做到的。
我在Ubuntu上遇到了类似的问题,即使多次安装最新版本的Nodejs,它仍然显示相同的旧版本;我发现每次都会安装相似的旧Debian软件包,即使执行了apt-get update命令。
最终,我通过清除旧的nodeJs,添加不同的存储库源,并按照以下方式正常安装nodeJs来解决了这个问题:
sudo apt-get purge --auto-remove nodejs
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
package.json
文件。
2. 找到"engines": { "node": "14.x" }
。
3. 把14.x
改成>=14.x
。yarn install --ignore-engines
或者
npm install --ignore-engines