如何修复 Angular ng: not found
问题:
尝试运行类似 ng build 的命令时,例如在 CI 设置中,你看到类似这样的错误消息
example-4.txt
首选解决方案:
仅在运行此命令的机器上,你没有全局安装 ng 命令。
然而,你的 node_modules 文件夹将有 @angular/cli 的本地安装。
为了使用它,将 ng 替换为 ./node_modules/.bin/ng。
例如,你的 package.json 的 scripts 部分
example-3.json
"build": "ng build"
},将被替换为
example-2.txt
"build": "./node_modules/.bin/ng build"
},替代解决方案:
在运行命令的机器上使用以下命令全局安装 ng
example-1.sh
Check out similar posts by category:
Angular
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow