在部署到AWS时,我得到了以下纱线错误
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时,我得到了以下纱线错误
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"
}
}
当前回答
对我来说,有效的方法是将Node更新到最新版本。根据您的操作系统选择任何教程。
升级Node.js到最新版本
其他回答
一个解决方案,就是一个黑客可以
yarn config set ignore-engines true
然而,如果你想要一个永久的解决方案是:
删除node_modules/, package-lock。Json & yarn.lock 再次运行yarn install或NPM I。
我的问题用yarn—ignore-engines解决了,但我不知道为什么以及如何解决。
我建议按照错误消息说的去做,检查你的node .js版本(node -v)。升级Node.js最简单的方法是使用n版本管理器:
$ npm install -g n
请安装Node的最新(n个最新)或LTS (n个LTS)版本。
有时您无法升级Node引擎(遗留项目、客户端需求等)。在这种情况下,我发现的解决方案是使用“选择性依赖解析”来降级有问题的版本,如Yarn中所述:
https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/
{
"name": "project",
"version": "1.0.0",
"dependencies": {
"left-pad": "1.0.0",
"c": "file:../c-1",
"d2": "file:../d2-1"
},
"resolutions": {
"d2/left-pad": "1.1.1",
"c/**/left-pad": "^1.1.2"
}
}
注意“决心”部分。您可以强制这些包使用降级版本(与您的旧Node引擎兼容)。
我不建议使用这个:
% yarn install --ignore-engines
它回避问题,而不是解决问题。 一个可能的解决方案是将节点更新到> 8.0版本。
% brew upgrade node
或者您可以尝试使用nodenv安装多个版本的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