'ng' 不被识别为内部或外部命令 [英] 'ng' is not recognized as an internal or external command

查看:59
本文介绍了'ng' 不被识别为内部或外部命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

删除以前版本的 Node.js 后,现在我已经安装了它的最新版本.我也安装了 @angular/cli .

但是当我尝试通过 CLI 创建新项目时,出现错误

<块引用>

'ng' 未被识别为内部或外部命令.

我已经多次使用命令和手动所有文件夹卸载了 Node.js,但在全新安装后仍然出现.

我尝试安装@angular/cli,但出现以下错误.

任何帮助将不胜感激.提前致谢.

解决方案

有两个原因.

  1. 可能是安装 Angular 后 PATH 上没有 npm 文件夹(npm install @angular/cli -g)

在您的系统或用户环境变量中附加以下条目:%USERPROFILE%\AppData\Roaming\npm

打开一个新的 windows shell 并且 ng 命令应该可用.

<块引用>

ng -v

<前>_ _ ____ _ ___/\ _ __ __ _ _ _||__ _ _ __/___|||_ _|/△ \ |'_ \/_` |||||/_` |'__|||||||/___ \||||(_| | |_| | | (_| | | | |___| |___ | |/_/\_\_||_|\__, |\__,_|_|\__,_|_|\____|_____|___||___/Angular CLI:1.7.2 节点:6.9.2 操作系统:win32 x64 Angular:...

  1. 您的 Angular 版本已损坏.从 Angular 5 开始,您不需要清理缓存.它会从腐败中自我修复.要检查缓存是否已损坏,请使用<块引用>

    npm 缓存验证

对于旧版本的 Angular,卸载使用:

<块引用>

npm 卸载 -g angular-clinpm uninstall --save-dev angular-cli

要安装新版本,请使用:

<块引用>

npm uninstall -g @angular/clinpm 缓存清理npm install -g @angular/cli@latest

祝你好运.

After removing the previous version of Node.js , now i have installed the latest version of it. I have also installed @angular/cli .

But when i am trying to create new Project through CLI , i am getting error

'ng' is not recognized as an internal or external command.

I have uninstalled Node.js several time using command and manually all folder but still it coming after fresh installation.

I have tried to install @angular/cli but getting below error.

Any help will be much appreciated. Thanks in Advance.

解决方案

There are two reasons.

  1. It could be you do not have npm folder on your PATH after installing Angular (npm install @angular/cli -g)

Append the below entry in your system or user environment variable: %USERPROFILE%\AppData\Roaming\npm

Open a new windows shell and ng command should be available.

ng -v

 
   _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.7.2 Node: 6.9.2 OS: win32 x64 Angular: ...

  1. 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 cache verify

For older version of Angular, uninstall using:

npm uninstall -g angular-cli npm uninstall --save-dev angular-cli

To install new version, use:

npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli@latest

Good luck.

这篇关于'ng' 不被识别为内部或外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆