Javascript 在 Windows 10 上安装 Angular-CLI
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39743890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing Angular-CLI on Windows 10
提问by mukesh51
I had installation issues of angular-cli on Windows 10 system. The errors were related to Python dependencies and node-gyp. Something as below :
我在 Windows 10 系统上遇到了 angular-cli 的安装问题。这些错误与 Python 依赖项和 node-gyp 相关。如下:
>[email protected] install C:\Users\UserName\AppData\Roaming\npm\node_modules\angular-cli\node_modules\execSync
node install.js
[execsync v1.0.2] Attempting to compile native extensions.
{ Error: spawn node-gyp ENOENT
at exports._errnoException (util.js:1007:11)
回答by ahmadali shafiee
Update
更新
this seems to be fixed in newer releases and this solution is no longer required.
这似乎在较新的版本中得到修复,并且不再需要此解决方案。
since mukesh51 is not answering his own question and Bhargav Rao removed mukesh51's answer from the question itself, I'm putting the answer here:
由于 mukesh51 没有回答他自己的问题,而 Bhargav Rao 从问题本身中删除了 mukesh51 的回答,我将答案放在这里:
the installation seems to work in these steps:
安装似乎按以下步骤工作:
npm install -g node-gypnpm install -g windows-build-toolsnpm install -g @angular/cli
npm install -g node-gypnpm install -g windows-build-toolsnpm install -g @angular/cli
I took these steps from here.
我从这里采取了这些步骤。
回答by vivek_waghmare
Uninstall
卸载
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
Update Global package
更新全局包
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest
回答by Glin Zachariah
I too faced the same issue initially when I installed angular directly using bash. The installation was error completely. Then I attempted to install locally in my project (without removing the global one). That appeared to have solved the problem but got an error on creating a new app.
当我直接使用 bash 安装 angular 时,我最初也遇到了同样的问题。安装完全错误。然后我尝试在我的项目中本地安装(不删除全局安装)。这似乎解决了问题,但在创建新应用程序时出错。
So i uninstalled everything :
所以我卸载了所有东西:
npm uninstall -g @angular/cli
and the reinstalled Angular using Windows Power Shell(as Admin)
以及使用 Windows Power Shell(作为管理员)重新安装的Angular
npm install -g @angular/cli
This solved the entire problem! Hope it helps!
这解决了整个问题!希望能帮助到你!
回答by Sudheer Eega
Use windows power shell to install angular-cli. It will run without any issues.
使用 windows power shell 安装 angular-cli。它将毫无问题地运行。
回答by Juanita
Windows 10 Solution
Windows 10 解决方案
Look back at the trace of installation steps ... you may see that it found the Angular binary in the following location:
回顾安装步骤的踪迹……你可能会看到它在以下位置找到了 Angular 二进制文件:
C:\Program Files\Git\usr\local\node_modules\@angular\cli\bin
C:\Program Files\Git\usr\local\node_modules\@angular\cli\bin
I added an ENVT variable using this path and ngworked fine after that
我使用此路径添加了一个 ENVT 变量,之后ng工作正常
回答by Amit kumar
I tried using npm install -g @angular/clinpm downloaded files successfully and copied files to AppData but not able to use ng -vAfter that, I tried following:
我尝试使用npm install -g @angular/clinpm 下载文件成功并将文件复制到 AppData 但无法使用ng -v之后,我尝试了以下操作:
npm cache clean --force
npm cache clean --force
Removes npm cache forcefully if you get warning using npm cache clean.
如果使用npm cache clean.
Then try
然后试试
npm install -g @angular/cli@latest
npm install -g @angular/cli@latest
I have successfully installed by trying the above solution in Windows10.
通过在 Windows10 中尝试上述解决方案,我已成功安装。
回答by Pavel Dobrovolskyi
Both the CLI and generated project have dependencies that require Node 8.9 or higher, together with NPM 5.5.1 or higher.
CLI 和生成的项目都具有需要 Node 8.9 或更高版本以及 NPM 5.5.1 或更高版本的依赖项。
try update node.js and npm
尝试更新 node.js 和 npm
回答by Leo Lanese
npm uninstall -g @angular/cli npm install -g @angular/cli
npm uninstall -g @angular/cli npm install -g @angular/cli
- if doesn't work: Close the terminal, open a new one or use CMD or Git for windows instead.
- 如果不起作用:关闭终端,打开一个新终端或使用 CMD 或 Git for windows 代替。

