npm 此版本的CLI仅与Angular版本^14.0.0兼容

szqfcxe2  于 2022-11-24  发布在  Angular
关注(0)|答案(1)|浏览(283)

出现以下错误:

This version of CLI is only compatible with Angular versions ^14.0.0,
but Angular version 15.0.0 was found instead.

Please visit the link below to find instructions on how to update Angular.
https://update.angular.io/

我将Angular更新为v15,删除了node_models和package-lock.json,但仍然出现此错误。
ng v显示我的版本是好的。我也改变了我的构建器回到默认的一个"builder": "@angular-devkit/build-angular:browser"
如何解决这个问题?

col17t5w

col17t5w1#

你在编译过程中看到任何问题了吗?我也有同样的问题。在我这边,它的发生是因为问题ngcc...

....
....
- @ng-bootstrap/ng-bootstrap [esm2015/esm2015] (git+https://github.com/ng-bootstrap/ng-bootstrap.git)
- @ng-bootstrap/ng-bootstrap [main/umd] (git+https://github.com/ng-bootstrap/ng-bootstrap.git)
- ng-bullet [fesm5/esm5] ()
- ng-bullet [esm2015/esm2015] ()
- ng-bullet [esm5/esm5] ()
- ng-bullet [main/umd] ()
Warning: Unable to fully load C:/.../node_modules/ng-bullet/bundles/ng-bullet.umd.js for source-map flattening: Cannot read properties of null (reading 'replace')
Warning: Unable to fully load C:/.../node_modules/ng-bullet/bundles/ng-bullet.umd.js for source-map flattening: Cannot read properties of null (reading 'replace')
Error: Error when flattening the source-map "C:..../node_modules/ng-bullet/bundles/ng-bullet.umd.js.map" for "C:/.../node_modules/ng-bullet/bundles/ng-bullet.umd.js": TypeError: Cannot read properties of null (reading 'rawMap')
Encourage the library authors to publish an Ivy distribution.

    ng version:
    Package                         Version
    ---------------------------------------------------------
    @angular-devkit/architect       0.1402.10
    @angular-devkit/build-angular   15.0.0
    @angular-devkit/core            15.0.0
    @angular-devkit/schematics      15.0.0
    @schematics/angular             15.0.0
    rxjs                            6.6.0
    typescript                      4.8.4

修复方法:

更新serve下的angular.json

from:  "builder": "@angular-builders/custom-webpack:dev-server",
to: "builder": "@angular-devkit/build-angular:dev-server",

相关问题