今天,我将我的 Angular cli 更新到了最新版本,并遇到了一个错误,导致我无法创建一个新的 Angular 项目。以下是我执行后得到的错误日志ng new app-name
:
Error: Schematic "ng-new" not found in collection "@schematics/angular".
at SchematicEngine.createSchematic (C:\Users\xyz\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\src\engine\engine.js:155:23)
at CollectionImpl.createSchematic (C:\Users\xyz\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\src\engine\collection.js:12:29)
at NodeWorkflow.execute (C:\Users\xyz\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\tools\workflow\node-workflow.js:70:38)
at Promise (C:\Users\xyz\node_modules\@angular\cli\models\schematic-command.js:141:22)
at new Promise (<anonymous>)
at NewCommand.runSchematic (C:\Users\xyz\node_modules\@angular\cli\models\schematic-command.js:140:16)
at NewCommand.<anonymous> (C:\Users\xyz\node_modules\@angular\cli\commands\new.js:77:25)
at Generator.next (<anonymous>)
at C:\Users\xyz\node_modules\@angular\cli\commands\new.js:7:71
at new Promise (<anonymous>)
为了自己解决问题,我已经重新安装了angular cli和npm两次以上。包的版本如下:
Package Version
------------------------------------------------------
@angular-devkit/architect 0.6.0
@angular-devkit/core 0.6.0
@angular-devkit/schematics 0.6.0
@schematics/angular 0.6.0
@schematics/update 0.6.0
rxjs 6.1.0
Angular Cli 6.0.0
Node 8.11.1
npm 5.6.0
任何帮助,将不胜感激。
编辑:我从安装有角度全局包的地方运行ng new,我可以从那里创建一个应用程序。从其他任何地方运行它会产生错误。