我在安装 angular-cli 时遇到了麻烦,因为它无法识别我的 git bash 中的 ng 命令,但它可以在 Windows 7 上的 cmd 中运行。
我在网上寻找了一些问题,但我并没有真正找到解决方案。
在这里,错误:
ng -v
module.js:549
throw err;
^
Error: Cannot find module 'C:\Program
Files\Git\node_modules\@angular\cli\bin\ng'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
这个错误发生在我在全局安装 Node 和 angular-cli 后第一次使用 ng 时。
当我在 Windows 10 上使用笔记本电脑时,我没有收到此错误。
原文由 Romain Rnd 发布,翻译遵循 CC BY-SA 4.0 许可协议
问题:
解决方案:
删除 C:\Users\Satish\AppData\Roaming\npm\node_modules@angular 文件夹,如果它在卸载后仍然存在
全局重新安装 angular-cli