在部署到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" 
  }
}

当前回答

我现在发现了这个问题,用一个旧代码,然而,我解决了它: 纱升级

其他回答

你可以试着忽略引擎:

$ 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

您需要升级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/

我建议按照错误消息说的去做,检查你的node .js版本(node -v)。升级Node.js最简单的方法是使用n版本管理器:

$ npm install -g n

请安装Node的最新(n个最新)或LTS (n个LTS)版本。

我的问题用yarn—ignore-engines解决了,但我不知道为什么以及如何解决。

我不建议使用这个:

% 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