简体   繁体   English

Windows 10 中的 npm 安装错误 ( npm install -g angular-cli )

[英]npm install error ( npm install -g angular-cli ) in windows 10

node -v节点 -v

v4.5.0 v4.5.0

npm -v npm -v

5.0.1 5.0.1

Has anyone faced this kind of issue while installing angular-cli in windows 10?有没有人在 Windows 10 中安装 angular-cli 时遇到过这种问题?

Try the following:请尝试以下操作:

step 0: run this command第 0 步:运行此命令

npm uninstall -g @angular/cli
npm cache clean

step 1: delete this folder: C:\\Users\\%YOUR-USERNAME%\\AppData\\Roaming\\npm步骤 1:删除此文件夹: C:\\Users\\%YOUR-USERNAME%\\AppData\\Roaming\\npm

step 2: uninstall Nodejs from Windows第 2 步:从 Windows 卸载 Nodejs

step 3: restart your PC第 3 步:重新启动 PC

step 4: install a fresh copy of Nodejs from here: https://nodejs.org/en/第 4 步:从这里安装 Nodejs 的新副本: https ://nodejs.org/en/

step 5: install the CLI globally第 5 步:全局安装 CLI

npm install -g @angular/cli@latest

try this :试试这个:

$ npm remove -g angular-cli
$ npm cache clean
$ npm install -g angular-cli

Check the path(npm -v, node -v)ie for Setting Path variable https://stackoverflow.com/a/32159233/4720950检查 path(npm -v, node -v)ie 以设置路径变量https://stackoverflow.com/a/32159233/4720950

User Variable C:\Users\Username\AppData\Roaming\npm 
System Variable C:\Program Files\nodejs

Restart System & update,clean npm https://stackoverflow.com/a/45020014重启系统和更新,清理 npm https://stackoverflow.com/a/45020014

npm install npm@latest -g
npm cache clean

Uninstall prev angular cli and then install angular cli again卸载prev angular cli,然后再次安装angular cli

npm uninstall -g angular-cli
npm install -g @angular/cli

I had this problem recently running on a Windows box.我最近在 Windows 机器上运行时遇到了这个问题。

To solve: using gitbash:解决方法:使用gitbash:

npm uninstall -g @angular/cli
npm cache verify

uninstall node using the uninstall option on the Windows menu > Node using gitbash: cd ~/AppData/Roaming rm -rf npm rm -rf npm-cache使用 Windows 菜单上的卸载选项卸载节点 > 使用 gitbash 的节点: cd ~/AppData/Roaming rm -rf npm rm -rf npm-cache

RESTART WINDOWS : You must restart windows RESTART WINDOWS :您必须重新启动 Windows

reinstall node.js重新安装 node.js

npm i @angular/cli -g

That worked.那奏效了。

  1. Delete c:/users/{accountname}/AppData/Roaming/npm/node_modules/@angular删除 c:/users/{accountname}/AppData/Roaming/npm/node_modules/@angular
  2. Delete c:/users/{accountname}/AppData/Roaming/npm/ng删除 c:/users/{accountname}/AppData/Roaming/npm/ng
  3. Delete c:/users/{accountname}/AppData/Roaming/npm/ng.cmd删除 c:/users/{accountname}/AppData/Roaming/npm/ng.cmd
  4. Delete c:/users/{accountname}/AppData/Roaming/npm/ng.ps1删除 c:/users/{accountname}/AppData/Roaming/npm/ng.ps1
  5. run this command in cmd在 cmd 中运行此命令

npm install -g @angular/cli npm install -g @angular/cli

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM