node.js 无法使用 npm 安装 @angular/cli
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47670693/
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
Not able to install @angular/cli using npm
提问by Rajpurohit
I am new to "@angular/cli", I have tried every thing but could not install. I am tired now please some one can help me to install angular 4 "@angular/cli" in my system.
我是“@angular/cli”的新手,我尝试了所有方法但无法安装。我现在累了,请有人可以帮助我在我的系统中安装 angular 4 "@angular/cli"。
and when I am installing "npm install -g @angular/cli" then getting

当我安装“npm install -g @angular/cli”然后得到

after installing node -v 6 I am getting below erorr

please suggest me where actually I am wrong.
请建议我实际上我错在哪里。
回答by Saurabh Agrawal
It could be issue with your node version. I will suggest you to reinstall node and try it again.
您的节点版本可能有问题。我会建议您重新安装节点并重试。
Or you can also try to clean node cache of using npm cache clean --force
或者您也可以尝试清理使用的节点缓存 npm cache clean --force
回答by ga.breban
My friend,
我的朋友,
Please try: npm cache clean --force. Maybe your npm cache got confused.
请尝试:npm cache clean --force。也许你的 npm 缓存混淆了。
回答by Rakesh Roy
List of Npm registry
Npm 注册表列表
- https://registry.npmjs.org/(Dfault One)
- http://r.cnpmjs.org/
- https://registry.npm.taobao.org/
- https://registry.nodejitsu.com/
- http://registry.mirror.cqupt.edu.cn
- https://skimdb.npmjs.com/registry
- https://registry.npmjs.org/(错误一)
- http://r.cnpmjs.org/
- https://registry.npm.taobao.org/
- https://registry.nodejitsu.com/
- http://registry.mirror.cqupt.edu.cn
- https://skimdb.npmjs.com/registry
To switch just type
要切换只需键入
npm config set registry "https://registry.npmjs.com/"
Replace the registry url with the above urls check which one works for you.
将注册表 url 替换为上述 url 检查哪个适合您。
I am from india so i used http://r.cnpmjs.org/and the same error got resolved.
我来自印度,所以我使用过http://r.cnpmjs.org/,同样的错误得到了解决。
Note: Please use npm cache clear(To clear cache ) and npm cache verify(To verify its clear or not), This Method works for me
注意:请使用npm cache clear(清除缓存)和npm cache verify(验证是否清除),此方法适用于我
回答by Robin Dijkhof
First try updating NodeJS(8.9.3) and npm(5.6.0). These are the LTS versions. For Node this can be important! If that doesn't work, follow this installation guidefor windows.
首先尝试更新 NodeJS(8.9.3) 和 npm(5.6.0)。这些是 LTS 版本。对于 Node,这可能很重要!如果这不起作用,请按照此Windows安装指南进行操作。
回答by rach8garg
Make sure you are not connected to VPN while installation is on.
确保在安装过程中您没有连接到 VPN。
Also, please cleanup your node_modules folder before your next try. I use the command rimraf node_modulesto remove this directory in windows.
另外,请在下次尝试之前清理您的 node_modules 文件夹。我使用命令rimraf node_modules在 Windows 中删除此目录。
Lastly try running npm install -g @angular/cli@latest
最后尝试运行 npm install -g @angular/cli@latest
回答by Ifesinachi Bryan
run npm install -g @angular/cli@latestin command prompt as an admin.
以管理员身份在命令提示符中运行 npm install -g @angular/cli@latest。
right click the windows button, click on command propmt (Admin)or windows power shell(Admin)depending on your windows version. Then type the command and run it.
右键单击 Windows 按钮,根据您的 Windows 版本单击命令提示(管理员)或windows power shell(管理员)。然后输入命令并运行它。
Most times, you could get issues when you want to install as a normal user considering the fact that you are using the -g (global) flag.
大多数情况下,考虑到您正在使用 -g(全局)标志这一事实,当您想以普通用户身份安装时,您可能会遇到问题。
回答by Duncan
It is possible your npm cache has a corrupted file, perhaps it partially downloaded something and then got an error. Try npm cache clean --forceand see if that helps.
您的 npm 缓存可能有一个损坏的文件,也许它部分下载了某些内容然后出现错误。试试看npm cache clean --force是否有帮助。
If that doesn't help look in the log file given in the error message. Find the unexpected end of JSON inputmessage in the log file and look before it to see if there are any other hints to the problem.
如果这没有帮助,请查看错误消息中给出的日志文件。unexpected end of JSON input在日志文件中找到该消息并查看它之前是否有任何其他问题的提示。
You updated your question with a new error message. That one is more specific about the corrupted file. Try removing the cli-1.5.5.tgzfile from the path specified and try again. If you are using a web proxy on your network then it is also possible that your proxy has stored a corrupted cache: if you are able then turn off any proxies configured for your system and try a direct download.
您使用新的错误消息更新了您的问题。那个更具体地关于损坏的文件。尝试cli-1.5.5.tgz从指定的路径中删除文件,然后重试。如果您在网络上使用 Web 代理,那么您的代理也可能存储了损坏的缓存:如果可以,请关闭为您的系统配置的所有代理并尝试直接下载。
回答by Manzer
Perhaps you are missing space- npm install -g @angular/cli@latest
也许您缺少空间- npm install -g @angular/cli@latest
1) Install node.js and check and node -v in command prompt. (Node.js
through website).
2) npm install -g @angular/cli@latest (run in command prompt).
Refer this link for further help
https://github.com/angular/angular-cli
https://github.com/angular/angular-cli
3) Check node -version
4) Check npm -version
5) check ng -version
If already installed, then uninstall it and install again,
npm uninstall -g @angular/cli
npm cache clean
回答by Shiha Mohan
Both the CLI and generated project have dependencies that require Node 6.9.0 or higher, together with NPM 3 or higher.
CLI 和生成的项目都具有需要 Node 6.9.0 或更高版本以及 NPM 3 或更高版本的依赖项。
Try using different Node version.
尝试使用不同的 Node 版本。
回答by Muthamizhchelvan. V
We too have the same kind of issue with user loginthen we tried from Administratorlogin its worked for us. Please do the same it may fix for you too.
我们也有同样的用户登录问题,然后我们尝试从管理员登录,它对我们有用。请做同样的事情,它也可能为您解决。

