node.js - Yarn 错误地报告不兼容的节点版本失败
问题描述
我正在尝试yarn
在我的项目中运行命令,但它失败了,报告了不兼容的节点版本。
奇怪的是,我的版本node
is 12.7.0
,而不是13.0.0-nightly2019072543e5478e2f
Yarn 报告的那样。
这是怎么回事?
注意:我使用的是 Ubuntu 18.04 LTS,它的 Node 版本已经过时,但我使用 NVM 将其更新为 12.7.0。
命令输出
$ yarn
yarn install v1.17.3
warning You are using Node "13.0.0-nightly2019072543e5478e2f" which is not supported and may encounter bugs or unexpected behavior. Yarn supports the following semver range: "^4.8.0 || ^5.7.0 || ^6.2.2 || >=8.0.0"
[1/4] Resolving packages...
[2/4] Fetching packages...
error xmlbuilder@9.0.7: The engine "node" is incompatible with this module. Expected version ">=4.0". Got "13.0.0-nightly2019072543e5478e2f"
error Found incompatible module.
$ node --version
v12.7.0
$ nvm list
v12.6.0
-> v12.7.0
system
default -> node (-> v12.7.0)
node -> stable (-> v12.7.0) (default)
stable -> 12.7 (-> v12.7.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/dubnium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.0 (-> N/A)
lts/dubnium -> v10.16.0 (-> N/A)
解决方案
我也看到了这个问题,输出如下:
The engine "node" is incompatible with this module. Expected version "^12.1.0". Got "14.18.0"
在我的package.json
中,我发现: "engines": { "node": "^12.1.0", "npm": ">= 5" }
我使用npm install -g n
. 请注意,n 仅适用于 Linux/MacOS。Windows 可以使用 NVM 来达到同样的目的。然后我运行n 12.1.0
并安装了 Node 版本 12.1.0,Yarn 现在很高兴。
https://blog.logrocket.com/switching-between-node-versions-during-development/ - 有关更改节点版本的说明。
推荐阅读
- reactjs - Auth.currentUser Info() 不显示用户属性反应 Native Aws App
- python-2.7 - 安装python包时出现egginfo错误
- java - 需要从用户那里为每个学生生成卷号吗?
- python - 在 ms 访问中看不到由 pyodbc 创建的表
- php - laravel 急切加载“with”
- javascript - 从 Firebase 获取数据到 Ionic(Angular)
- apache - SOLR 的 http 错误 404
- hyperledger-fabric - 超级账本结构和以太坊集成
- ruby-on-rails - Heroku Scheduler 任务未按预期运行
- javascript - Vuejs - 将原始 html 链接渲染到