npm WARN EBADENGINE 的原因?

Cause of npm WARN EBADENGINE?

当使用 npm install 生成 package-lock.json 文件时,出现此错误:

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'app@1.0.0',
npm WARN EBADENGINE   required: { node: '16.0.0' },
npm WARN EBADENGINE   current: { node: 'v16.10.0', npm: '7.24.0' }
npm WARN EBADENGINE }

这里有点困惑。它需要节点 v16.0.0,这就是我正在使用的节点。 npm v7.x.x 与该版本的节点不兼容吗?

您正在使用 16.10.0,但消息说它需要 16.0.0。不是 16.0.0 或更高版本。它需要正好 16.0.0.

如果是您的 package.json 引擎字段导致此问题,请将其更改为 16.0.0 或更高版本:

  "engines": {
    "node": ">=16.0.0"
  },

package.lock.json,这样做:

 "engines": {
    "node": ">=0.7.0 <16.15.0"
  }

这将几乎支持所有 nodejs npm 模块。

看到这一行

npm WARN EBADENGINE   required: { node: '>= 0.8.0 < 0.11.0' },

这意味着节点引擎的范围应介于 0.8.0 和 0.11.0 之间,例如 engines": {"node": ">=0.7.0 <16.15.0"}engines": {"node": ">=0.9.0 <11.15.0"}