运行windows 7 Professional 32bit。

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

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

我做错了什么?


当前回答

今天我也遇到了同样的问题,我走过了下面这条路—— (%USERPROFILE%\AppData\Roaming\npm),当我清除npm目录下的所有内容时,才知道有一些垃圾数据。现在当我运行(npm安装命令再次)。现在一切正常。

其他回答

NPM install -g @angular/cli代替了NPM install @angular/cli

我必须将npm路径添加到user path环境变量中。你可以以管理员身份运行以下PowerShell脚本:

$path = npm config get prefix    
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")

if (($userPath -split ';') -notcontains $path) 
{
    [Environment]::SetEnvironmentVariable("PATH", ('{0};{1}' -f $userPath, $path), "User")
}

这个方法几乎适用于我,但我必须使用:%USERPROFILE%\AppData\Roaming\npm . 在环境变量中…/ /系统变量的路径

然后当我执行CMD: "ng -v"时,我得到了angular cli的正确响应。

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".

导航到要创建应用程序的目录并运行命令:

PATH="节点所在的路径";%PATH%