我尝试在 package.json 中指定 Node 引擎以同时接受 8
和 10
版本。
我试着输入这个:
"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/