终极解决方案:Package install failed, see above. The Schematic workflow failed. See above,angualr新建项目报错

解决CLI安装问题:ngnew项目名 --skip-install
当遇到CLI安装卡住的问题时,传统的卸载重装方法可能无效。博主分享了一个新的解决方案:在创建新项目时使用'ngnew项目名 --skip-install'命令,该方法被证实可以成功解决问题,避免了繁琐的卸载和清理过程。

 相信很多小伙伴都是卡在这个地方

看了很多帖子,都是建议重新卸载cli,然后清除缓存,再重新安装,我也尝试了这个方法,不是很OK

最后找到这个方法:

 ng new 项目名 --skip-install

亲测有效!(就是在结尾加上 --skip-install 就可以了)

PS E:\project\Demo> ng add ng-zorro-antd Skipping installation: Package already installed ✔ Enable icon dynamic loading [ Detail: https://ng.ant.design/components/icon/en ] No ✔ Set up custom theme file [ Detail: https://ng.ant.design/docs/customize-theme/en ] No ✔ Choose your locale code: zh_CN ✔ Choose template to create project: blank UPDATE src/app/app.html (287 bytes) ⠏ Installing packages (npm)...npm error code ERESOLVE npm error ERESOLVE could not resolve npm error npm error While resolving: ng-zorro-antd@20.3.1 npm error Found: @angular/core@20.3.0 npm error node_modules/@angular/core npm error @angular/core@"^20.2.0" from the root project npm error peerOptional @angular/core@"^20.0.0" from @angular/build@20.3.1 npm error node_modules/@angular/build npm error dev @angular/build@"^20.2.2" from the root project npm error 7 more (@angular/cdk, @angular/common, @angular/forms, ...) npm error npm error Could not resolve dependency: npm error peer @angular/animations@"^20.0.0" from ng-zorro-antd@20.3.1 npm error node_modules/ng-zorro-antd npm error ng-zorro-antd@"^20.3.1" from the root project npm error npm error Conflicting peer dependency: @angular/core@20.3.1 npm error node_modules/@angular/core npm error peer @angular/core@"20.3.1" from @angular/animations@20.3.1 npm error node_modules/@angular/animations npm error peer @angular/animations@"^20.0.0" from ng-zorro-antd@20.3.1 npm error node_modules/ng-zorro-antd npm error ng-zorro-antd@"^20.3.1" from the root project npm error npm error Fix the upstream dependency conflict, or retry npm error this command with --force or --legacy-peer-deps npm error to accept an incorrect (and potentially broken) dependency resolution. npm error npm error npm error For a full report see: npm error C:\Users\BIM01\AppData\Local\npm-cache\_logs\2025-09-18T07_21_31_054Z-eresolve-report.txt npm error A complete log of this run can be found in: C:\Users\BIM01\AppData\Local\npm-cache\_logs\2025-09-18T07_21_31_054Z-debug-0.log ✖ Package install failed, see above. The Schematic workflow failed. See above.
最新发布
09-19
Angular项目中使用 `ng add ng-zorro-antd` 命令安装 `ng-zorro-antd@20.3.1` 时出现的 `npm ERESOLVE` 依赖冲突问题,可尝试以下解决方法: #### 使用 `--legacy-peer-deps` 选项 `--legacy-peer-deps` 选项可让 `npm` 在安装时忽略对等依赖冲突。可使用该选项重新执行安装命令: ```bash ng add ng-zorro-antd@20.3.1 --legacy-peer-deps ``` #### 手动指定依赖版本 在 `package.json` 文件中手动指定 `@angular/core` 和 `@angular/animations` 的版本,确保它们相互兼容。示例如下: ```json { "dependencies": { "@angular/core": "20.3.1", "@angular/animations": "20.3.1", "ng-zorro-antd": "20.3.1" } } ``` 然后重新执行安装命令: ```bash ng add ng-zorro-antd@20.3.1 ``` #### 清理 `npm` 缓存 有时候,缓存的文件可能会导致依赖解析问题。可以清理 `npm` 缓存后再重新执行安装命令: ```bash npm cache clean --force ng add ng-zorro-antd@20.3.1 ``` #### 更新 `npm` 到最新版本 旧版本的 `npm` 可能存在一些依赖解析的问题,更新到最新版本可能会解决该问题: ```bash npm install -g npm@latest ``` 更新完成后,再次尝试安装: ```bash ng add ng-zorro-antd@20.3.1 ``` #### 使用 `yarn` 替代 `npm` `yarn` 是另一个包管理工具,有时候使用 `yarn` 可以避免一些 `npm` 遇到的依赖解析问题。首先安装 `yarn`: ```bash npm install -g yarn ``` 然后使用 `yarn` 执行安装命令: ```bash yarn ng add ng-zorro-antd@20.3.1 ```
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我是嚼嚼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值