【问题标题】:Yarn fails incorrectly reporting incompatible node versionYarn 错误地报告不兼容的节点版本失败
【发布时间】:2019-07-25 17:01:35
【问题描述】:

我试图在我的项目中运行yarn 命令,但它失败了,报告了不兼容的节点版本。

奇怪的是,我的 node 版本是 12.7.0,而不是 Yarn` 报告的 13.0.0-nightly2019072543e5478e2f

发生了什么事?

注意:我使用的是 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)

【问题讨论】:

  • 您是否尝试重新安装节点?
  • @GProst:我尝试使用 NVM 和 Ubuntu 的包管理器重新安装两者。没有帮助。

标签: node.js ubuntu yarnpkg ubuntu-18.04


【解决方案1】:

我也看到了这个问题,输出如下:

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 包管理器。请注意,n 仅适用于 Linux/MacOS。 Windows 可以使用 NVM 来达到同样的目的。 然后我运行n 12.1.0 并安装了 Node 版本 12.1.0,Yarn 现在很开心。

https://blog.logrocket.com/switching-between-node-versions-during-development/ - 关于更改节点版本的说明。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-21
    • 2021-11-18
    • 1970-01-01
    • 1970-01-01
    • 2020-11-17
    • 2022-06-11
    • 1970-01-01
    • 2021-10-11
    相关资源
    最近更新 更多