运行windows 7 Professional 32bit。
我试着在normal或admin下运行npm install -g angular-cli。
我还尝试将它添加到PATH: (C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng)下的环境变量中,也没有成功。
我做错了什么?
运行windows 7 Professional 32bit。
我试着在normal或admin下运行npm install -g angular-cli。
我还尝试将它添加到PATH: (C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng)下的环境变量中,也没有成功。
我做错了什么?
当前回答
对我来说,PATH环境变量有问题。我删除了所有与npm相关的路径,并在path的开头添加了这个文件夹:
c:\Users\<your-user-name>\AppData\Roaming\npm\
确保你有;之间的路径。
其他回答
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".
在我的情况下,我做了以下步骤。
所有程序-> Node JS->右键单击Node. JS命令提示符,选择属性和从目标字符串在结束复制下面
/k "C:\Program Files\nodejs\nodevars.bat"
我启动Visual Studio Code并打开下面的文件
C:\Users\gochinta\AppData\Roaming\Code\User\settings.Json,并给出如下
// Place your settings in this file to overwrite the default settings
{
"terminal.integrated.shellArgs.windows":
["/k", "C:\\Program Files\\nodejs\\nodevars.bat"]
}
现在我在Visual Studio Code终端窗口中输入ng -v,它工作了。
今天我也遇到了同样的问题,我走过了下面这条路—— (%USERPROFILE%\AppData\Roaming\npm),当我清除npm目录下的所有内容时,才知道有一些垃圾数据。现在当我运行(npm安装命令再次)。现在一切正常。
对我来说,PATH环境变量有问题。我删除了所有与npm相关的路径,并在path的开头添加了这个文件夹:
c:\Users\<your-user-name>\AppData\Roaming\npm\
确保你有;之间的路径。
关闭CMD并再次以管理员权限打开或重新启动系统。