首页 > 解决方案 > 尝试安装类验证器和类转换器时,NestJS“警告 EBADENGINE 不支持的引擎 @angulardevkit”

问题描述

我正在学习 NestJS 网站上的课程。我需要安装类验证器和类转换器npm i class-validator class-transformer

但是当我这样做时,我得到了错误:

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@angular-devkit/core@12.2.10',
npm WARN EBADENGINE   required: {
npm WARN EBADENGINE     node: '^12.14.1 || >=14.0.0',
npm WARN EBADENGINE     npm: '^6.11.0 || ^7.5.6',
npm WARN EBADENGINE     yarn: '>= 1.13.0'
npm WARN EBADENGINE   },
npm WARN EBADENGINE   current: { node: 'v16.11.0', npm: '8.0.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@angular-devkit/schematics@12.2.10',
npm WARN EBADENGINE   required: {
npm WARN EBADENGINE     node: '^12.14.1 || >=14.0.0',
npm WARN EBADENGINE     npm: '^6.11.0 || ^7.5.6',
npm WARN EBADENGINE     yarn: '>= 1.13.0'
npm WARN EBADENGINE   },
npm WARN EBADENGINE   current: { node: 'v16.11.0', npm: '8.0.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@angular-devkit/schematics-cli@12.2.10',
npm WARN EBADENGINE   required: {
npm WARN EBADENGINE     node: '^12.14.1 || >=14.0.0',
npm WARN EBADENGINE     npm: '^6.11.0 || ^7.5.6',
npm WARN EBADENGINE     yarn: '>= 1.13.0'
npm WARN EBADENGINE   },
npm WARN EBADENGINE   current: { node: 'v16.11.0', npm: '8.0.0' }
npm WARN EBADENGINE }

我不明白如何解决这个问题。

NestJS 和 Angular 似乎意识到了这个问题,因为这两个团队在 GitHub Memory 上进行了简短的讨论。最新版本的 Angular 不支持 npm 8 或更高版本?

但似乎 Angular 团队在 2021 年 10 月 20 日 - 4 天前的版本中对此进行了修复

我正在使用 Ubuntu 20.04
节点 16.11
npm 8

我需要做什么来解决这个问题?

标签: node.jsangularubuntunpmnestjs

解决方案


2021 年 11 月 18 日更新:

NestJS 已经更新了依赖项(特别是@nestjs/cli@8.1.5),所以现在您可以更新项目依赖项(只需运行npm update)并切换回使用 npm@8(只需运行npm install -g npm@8)。

原答案:

是的,你今天应该做的就是将 npm 降级到版本 7。为此,只需运行npm install -g npm@7.

Npm v8 支持已经添加到 angular ( https://github.com/angular/angular-cli/blob/master/CHANGELOG.md#12211-2021-10-20 ),但我们仍在等待 NestJS 更新依赖项。一旦发生这种情况,您应该能够通过运行切换回 npm v8 npm i -g npm@8


推荐阅读