简体   繁体   English

Git Bash 不适用于 npm、node、ng 命令,但所有这些命令都适用于 powershell windows 10

[英]Git Bash does not work for npm, node, ng commands but all these commands works in powershell windows 10

Few months back all worked well but now some update or something broke my setup for Angular development setup.几个月前一切正常,但现在一些更新或某些东西破坏了我的 Angular 开发设置。 I got all latest node, npm, ts, ng and VS code.我得到了所有最新的节点、npm、ts、ng 和 VS 代码。 Used to work well.曾经工作得很好。 But today, after few months i updated all and found that these commands for ng doesnot work in Git BASH MING64 command window.但是今天,几个月后我更新了所有内容,发现这些 ng 命令在 Git BASH MING64 命令窗口中不起作用。 All works well and in windows cmd and powershell.一切正常,在 windows cmd 和 powershell 中。 I noticed strange forward and backward slashes in path under git Bash window though.不过,我注意到 git Bash 窗口下的路径中有奇怪的向前和向后斜线。 My environment path for System and current user all set.我的系统和当前用户的环境路径都设置好了。

RonPC@RON-DESKTOP MINGW64 ~/Documents/VScode-Projects/AngularProjects/angular2020/jan2020 (master)
$ ng --version
C:\Users\RonPC\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

RonPC@RON-DESKTOP MINGW64 ~/Documents/VScode-Projects/AngularProjects/angular2020/jan2020 (master)
$ npm ng --version
C:\Users\RonPC\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

RonPC@RON-DESKTOP MINGW64 ~/Documents/VScode-Projects/AngularProjects/angular2020/jan2020 (master)
$ npx ng --version
C:\Users\RonPC\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

RonPC@RON-DESKTOP MINGW64 ~/Documents/VScode-Projects/AngularProjects/angular2020/jan2020 (master)
$ node v
C:\Users\RonPC\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

RonPC@RON-DESKTOP MINGW64 ~/Documents/VScode-Projects/AngularProjects/angular2020/jan2020 (master)
$ node --version
C:\Users\RonPC\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

RonPC@RON-DESKTOP MINGW64 ~/Documents/VScode-Projects/AngularProjects/angular2020/jan2020 (master)

anyone got tip to get it fixed.任何人都得到了修复的提示。 I tried installing git BASH again but no help.我再次尝试安装 git BASH 但没有帮助。 regards问候

Screenshot of path for system environment vars系统环境变量的路径截图

Screenshot showing my installed components of node, npm and ng显示我安装的 node、npm 和 ng 组件的屏幕截图

Solution:解决方案:

After going through numerous solution listed on different forums, re-installing Nodejs/Git Bash cmd, tinkering PATHS.. no luck.在经历了不同论坛上列出的众多解决方案后,重新安装 Nodejs/Git Bash cmd,修补路径……没有运气。

Very simple solution:非常简单的解决方案:

But i uninstalled "node" from Add Remove Programme --> deleted folder"npm" & "npm-cache" from location --> C:\\Users\\RonPC\\AppData\\Roaming但是我从“添加删除程序”中卸载了“节点”--> 从位置-> 删除文件夹“npm”和“npm-cache”--> C:\\Users\\RonPC\\AppData\\Roaming

Reinstalled Node.js(npm installed with it) and it worked like charm.重新安装了 Node.js(npm 安装了它),它的工作就像魅力一样。

Hopefully it saves anyone having trouble for this reason.希望它可以避免任何因此而遇到麻烦的人。

Regards问候

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

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