gpt4 book ai didi

node.js - 如何在使用 yarn 安装 npm 依赖项时忽略不兼容的引擎 "node"错误?

转载 作者:IT老高 更新时间:2023-10-28 21:56:40 31 4
gpt4 key购买 nike

鉴于此 package.json:

{
"name": "yarn-install-fail",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "2.x.x",
"s3-streams": "^0.3.0"
}
}

我可以通过 npm 成功安装依赖:

$ npm install

added 27 packages in 1.844s

然而 yarn 失败了:

$ yarn install
yarn install v0.24.5
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
error s3-streams@0.3.0: The engine "node" is incompatible with this module. Expected version "^1.2.0".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

看起来 yarn 在安装库 s3-streams@0.3.0 时遇到了问题,但我认为它会像 npm 那样安装所有依赖项。

最佳答案

您确实可以通过 --ignore-engines 忽略此类错误:

$ yarn install --ignore-engines
yarn install v0.24.5
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 1.41s.

这也记录在命令的帮助中:

$ 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.js - 如何在使用 yarn 安装 npm 依赖项时忽略不兼容的引擎 "node"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45088031/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com