在部署到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 .js版本(node -v)。升级Node.js最简单的方法是使用n版本管理器:
$ npm install -g n
请安装Node的最新(n个最新)或LTS (n个LTS)版本。
其他回答
你可以试着忽略引擎:
$ yarn install—忽略引擎
OR
$ yarn global添加<你的应用>—忽略引擎
通过运行以下命令,你可以看到所有你可以忽略的内容:
$ 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
很多答案说设置标志来忽略版本错误。
更好的选择是使用它作为提醒,将您的节点版本更新到您想要安装的包所支持的最新版本。
nvm install 16.16.0 # download & install locally on your system
nvm use 16.16.0 # update current project's .nvmrc file
注意,第二个命令将更新您的本地.nvmrc,该命令指定每个项目节点的版本。
节点生态系统更新很快,即使是“长期支持”(LTS)版本也会在大约3年后停止获得支持。使用此页面查看最新的LTS发布版本,并从错误消息中确保它与正在安装的包所期望的节点版本匹配。
对我来说,有效的方法是将Node更新到最新版本。根据您的操作系统选择任何教程。
升级Node.js到最新版本
有时您无法升级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引擎兼容)。
您需要升级node的版本。
我也遇到了同样的问题。
如果你使用Homebrew运行:
brew update # This updates Homebrew to latest version
brew upgrade node
如果你使用nvm运行:
nvm current node -v # Checks your current version
nvm install <version> # Example: nvm install 12.14.1
以上步骤请访问https://nodejs.org/en/download/
获取一个满足错误中的条件的版本,最新的版本应该可以工作。
更详细的演练:https://flaviocopes.com/how-to-update-node/