2017-10-07 111 views
3

我正在学习Angular,我的终端知识是初学者。在我安装了Angular之后,输入ng new my-project。我收到了回复ng: command not found。我已经看到其他帖子有这个问题,我已经卸载并重新安装npmngAngular - ng:没有找到的命令

我采取的最后一步是npm install -g @ angular/cli @ latest then ng new my-project。

然后我得到ng: command not found

感谢,

+0

npm的版本?节点?你使用什么操作系统?所有这些都与这个问题有关。请更新您的问题 –

回答

0

尝试与sudo全球安装角CLI:

sudo npm install -g @angular/cli 
0

删除节点,并使用NVM,而不是固定的很多问题。

从系统中删除节点

从这里https://github.com/creationix/nvm

安装NVM通过NVM安装节点:NVM安装

稳定运行NPM安装-g角CLI

LINK

0

*仅Windows *

线索是将条目排列在路径变量右侧。

由于NPM wiki tells us

由于安装程序放在C:\ Program Files文件(x86)的\之前的NodeJS C:\用户\\应用程序数据\漫游\ NPM PATH中,它总是使用的版本npm使用节点安装,而不是使用npm -g install npm @安装的npm版本。

所以,你的路径变量看起来像:

…;C:\<path-to-node-installation>;%appdata%\npm;…

现在你必须可能性:

  1. 交换两个条目,以便它看起来就像 …;%appdata%\npm;C:\<path-to-node-installation>;… 这将加载使用npm安装的npm版本(而不是使用节点),并使用安装的Agnular CLI版本。

  2. 如果您(因任何原因)喜欢使用与节点捆绑在一起的npm版本,请将直接路径添加到您的全球Angualr CLI版本。在此之后,您的路径变量应如下所示:…;C:\Users\<username>\AppData\Roaming\npm\node_modules\@angular\cli;C:\<path-to-node-installation>;%appdata%\npm;……;%appdata%\npm\node_modules\@angular\cli;C:\<path-to-node-installation>;%appdata%\npm;… 的简写形式。

这段时间以来一直为我工作。

0

刚刚安装npm install -g @ angular/cli @ latest

+0

这并没有提供答案,它已经在问题中说明了这一点已经尝试过。 –

+0

好的,但它的工作对我来说是如此贴。 –