运行windows 7 Professional 32bit。

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

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

我做错了什么?


当前回答

与其使用内置的命令提示符,不如开始使用NodeJS安装版本的命令提示符。然后它将完美地工作,没有任何问题。

其他回答

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

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

重新启动IDE。

我有同样的问题,Visual Studio代码不能在它的内置终端中运行任何ng命令。

我添加了%AppData%\npm到Windows 10的路径中,并且不需要重新启动,只是关闭和重新打开VS Code,它看不到它。

您可以这样办理登机手续。我也有同样的问题。首先,在环境变量中检查用户PATH。它必须指向%USERPROFILE%\AppData\Roaming\npm\node_modules\@angular\cli\

使用node.js命令提示符代替命令提示符。在安装的程序菜单中运行node.js命令提示符。点击开始,搜索node.js命令提示符。运行它,然后输入ng -v回车。它会起作用的。如果有帮助,请告诉我。

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

执行以下几行,以解决ng未找到和未定义版本的问题

卸载-g angular-cli

卸载angular-cli

NPM缓存清理

安装-g @angular/cli@latest