简体   繁体   English

升级到V15.1.2后无法通过Angular CLI生成组件

[英]Cannot generate components via Angular CLI after Upgrade to V15.1.2

My team recently upgraded a project to Angular V15.1.2 and since then I've not been able to run simple cli commands such as ng g c components/test .我的团队最近将一个项目升级到 Angular V15.1.2,从那时起我就无法运行简单的 cli 命令,例如ng g c components/test I'm not having the same issue in my other project that is running Angular 15.0.1, so at least that should rule out an error with my version of NPM or Node.我在运行 Angular 15.0.1 的其他项目中没有遇到同样的问题,所以至少应该排除我的 NPM 或 Node.js 版本的错误。 The following is the error that I receive:以下是我收到的错误:

An unhandled exception occurred: Cannot destructure property 'aliases' of 'collection.description.schematics[schematicName]' as it is undefined.发生未处理的异常:无法解构“collection.description.schematics [schematicName]”的属性“别名”,因为它未定义。 See "C:\Users\david\AppData\Local\Temp\ng-4fyV7s\angular-errors.log" for further details.有关详细信息,请参阅“C:\Users\david\AppData\Local\Temp\ng-4fyV7s\angular-errors.log”。

The following is the further details mentioned above:以下是上述进一步的细节:

[error] TypeError: Cannot destructure property 'aliases' of 'collection.description.schematics[schematicName]' as it is undefined. [错误] 类型错误:无法解构“collection.description.schematics [schematicName]”的属性“别名”,因为它未定义。 at GenerateCommandModule.getSchematics (C:\Projects\GitHub\app\node_modules@angular\cli\src\commands\generate\cli.js:141:29) at getSchematics.next () at GenerateCommandModule.getSchematicsToRegister (C:\Projects\GitHub\pau-pe-shutdownreporting\shutdown-app\node_modules@angular\cli\src\commands\generate\cli.js:158:76) at async GenerateCommandModule.builder (C:\Projects\GitHub\app\node_modules@angular\cli\src\commands\generate\cli.js:35:55) at async runCommand (C:\Projects\GitHub\app\node_modules@angular\cli\src\command-builder\command-runner.js:113:5) at async default_1 (C:\Projects\GitHub\app\node_modules@angular\cli\lib\cli\index.js:70:16)在 GenerateCommandModule.getSchematics (C:\Projects\GitHub\app\node_modules@angular\cli\src\commands\generate\cli.js:141:29) 在 getSchematics.next () 在 GenerateCommandModule.getSchematicsToRegister (C:\Projects\ GitHub\pau-pe-shutdownreporting\shutdown-app\node_modules@angular\cli\src\commands\generate\cli.js:158:76) 在异步 GenerateCommandModule.builder (C:\Projects\GitHub\app\node_modules@angular \cli\src\commands\generate\cli.js:35:55) 在异步运行命令 (C:\Projects\GitHub\app\node_modules@angular\cli\src\command-builder\command-runner.js:113: 5) 在异步 default_1 (C:\Projects\GitHub\app\node_modules@angular\cli\lib\cli\index.js:70:16)

This is on a Windows 10 machine within a Git Bash terminal within VSCode.这是在 Windows 10 机器上的 Git Bash 终端内的 VSCode。 Others on my team are also having the same issue, so it may be something with the project setup after the upgrade.我团队中的其他人也遇到了同样的问题,因此升级后可能与项目设置有关。

Evidently my issue was caused by some issues while the project was being upgraded that caused the angular packages to not all be upgraded correctly.显然我的问题是由项目升级时的一些问题引起的,导致 angular 包没有全部正确升级。 If you are running into this issue, check that @angular/compiler-cli has been upgraded to the same level as @angular/cli.如果您遇到此问题,请检查@angular/compiler-cli 是否已升级到与@angular/cli 相同的级别。

Hi I was having the same problem today, I fixed with:嗨,我今天遇到了同样的问题,我修复了:

npm uninstall -g @angular/cli
npm install -g @angular/cli@latest


npm install
ng g c components/test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM