无法将"ng"识别为内部或外部命令 [英] 'ng' is not recognized as an internal or external command
问题描述
在删除了先前版本的Node.js之后,现在我已经安装了它的最新版本.我还安装了@ angular/cli.
After removing the previous version of Node.js , now i have installed the latest version of it. I have also installed @angular/cli .
但是当我尝试通过CLI创建新项目时,出现错误
But when i am trying to create new Project through CLI , i am getting error
'ng'不被识别为内部或外部命令.
'ng' is not recognized as an internal or external command.
我已经多次使用命令卸载了Node.js,并手动卸载了所有文件夹,但是在重新安装后仍然会卸载它.
I have uninstalled Node.js several time using command and manually all folder but still it coming after fresh installation.
我尝试安装@ angular/cli,但出现错误.
I have tried to install @angular/cli but getting below error.
任何帮助将不胜感激. 预先感谢.
Any help will be much appreciated. Thanks in Advance.
推荐答案
有两个原因.
- 可能是您在安装Angular(
npm install @angular/cli -g
)后在PATH
上没有npm文件夹
- It could be you do not have npm folder on your
PATH
after installing Angular (npm install @angular/cli -g
)
在系统或用户环境变量中添加以下条目: %USERPROFILE%\ AppData \ Roaming \ npm
Append the below entry in your system or user environment variable: %USERPROFILE%\AppData\Roaming\npm
打开一个新的Windows shell,并且ng
命令应该可用.
Open a new windows shell and ng
command should be available.
ng -v
ng -v
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 1.7.2 Node: 6.9.2 OS: win32 x64 Angular: ...
- 您的Angular版本已损坏.从Angular 5开始,您不需要清理缓存.它可以从腐败中自我修复. 要检查缓存是否已损坏,请使用
- Your Angular version is corrupted. As of Angular 5 you don't need to clean the cache. It self-heals from corruptions. To check if the cache is corrupted, use
npm缓存验证
npm cache verify
对于较旧版本的Angular,请使用以下命令进行卸载:
For older version of Angular, uninstall using:
npm卸载-g angular-cli npm卸载--save-dev angular-cli
npm uninstall -g angular-cli npm uninstall --save-dev angular-cli
要安装新版本,请使用:
To install new version, use:
npm卸载-g @ angular/cli npm缓存清理 npm install -g @ angular/cli @ latest
npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli@latest
祝你好运.
这篇关于无法将"ng"识别为内部或外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!