javascript - package.json 中的 Node 引擎 8.x 或 10.x

标签 javascript node.js npm package.json yarnpkg

我尝试在 package.json 中指定 Node 引擎以同时接受 810 版本。

我试着输入这个:

"engines": {
  "node": "8.x|10.x"
},

但运行 yarn 会导致:

The engine "node" is incompatible with this module. Expected version "8.x|10.x"

如果我替换为:

"engines": {
  "node": "10.x"
},

...它可以工作(即没有错误)。

有没有办法在 package.json 中接受两个版本的 Node 引擎?

最佳答案

您只需要双管道 || 而不是单管道。

"engines": {
  "node": "^8 || ^10"
}

将匹配 v8.x.x 或 v10.x.x 但 v9。

您可以阅读更多信息 here , 或 https://github.com/npm/node-semver#versions

关于javascript - package.json 中的 Node 引擎 8.x 或 10.x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51596127/

相关文章:

javascript - Web 可访问性 - 屏幕阅读器在鼠标悬停时和按 Tab 键时以不同方式读取 HTML 元素

javascript - 这个 JavaScript 可以优化吗?

javascript - 从字符串创建对象,javascript

javascript - 正则表达式帮助 : How do I find a match for a character that has a particular character coming before it?

javascript - Express.js 接下来类似于使用生成器的功能

javascript - 连接 NPM 脚本命令?

node.js - 只运行一次但在多个主机上运行的 Cron 样式调度程序

node.js - npm 不构建 Contextify Release - 找不到 Node 路径?

pdf - nodejs npm库来访问和修改Microsoft Word文档

javascript - 通过 npm 获取 Highcharts 样式模式