运行windows 7 Professional 32bit。

我试着在normal或admin下运行npm install -g angular-cli。

我还尝试将它添加到PATH: (C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng)下的环境变量中,也没有成功。

我做错了什么?


当前回答

将新路径设置为c:\ users \你的名字\ appdata \漫游\npm\node_modules\@angular\cli\bin\ng现在对我来说很好

其他回答

我在Windows 7上也遇到了同样的问题,64位运行npm v3.10.8。

我按照建议添加了路径:(C:\Users.....(你的用户名)\AppData\Roaming\npm\node_modules\angular-cli\bin\ng)和卸载angular-cli。 在这之后,我清除npm缓存通过npm缓存清理提示这里https://blogs.msdn.microsoft.com/matt-harrington/2012/02/23/how-to-fix-node-js-npm-permission-problems/。这保证了没有剩菜。 用npm install -g angular-cli重新安装angular-cli,瞧。 希望对大家有用!

在系统env设置中,将node_modules下的.bin文件夹中的ng命令路径添加到path变量。

例:将C:\testProject\node_modules\.bin\添加到PATH中

重新启动IDE。

我根据图解决了这个问题:

在CMD下运行

 npm install -g @angular/cli

然后

(在Windows 10中打开)控制面板\所有控制面板项\系统 或按图

步骤1:

第二步:

步骤3:

目的:

添加缺少的ng路径

下面是你需要添加的新环境变量:c:\ users \ pk\ appdata \漫游\npm\node_modules\@angular\cli\bin

最后,重新启动所有打开的命令提示符并重试。

如果您在执行上述步骤后仍然得到错误。然后试试下面的建议。

因为它是一个节点脚本。我现在使用下面的选项来创建。

\ users \Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng版本

可能需要符号链接。没有进一步研究。

进一步研究: C:\Users\Administrator\AppData\Roaming\npm;

在Windows中,npm。CMD文件在上述路径下。如果设置了上述环境变量,则可以执行为 ng版本 ng init

I was having the same issue when tried with the syntax "ng new " and solved that simply by updating the existing node version from 5.x.x to 8.x.x. After successful updation of node, the syntax worked perfectly for me. Please update the existing version of node. As it is clearly mentioned in angular documentation that these commands require the node version >= 6.9.x. For reference please check https://angular.io/guide/quickstart. It clearly states "Verify that you are running at least node 6.9.x and npm 3.x.x by running node -v and npm -v in a terminal/console window. Older versions produce errors, but newer versions are fine".