错误:EPERM无法安装@ angular / cli

时间:2017-04-26 06:19:45

标签: node.js angular angular2-cli

我已尝试使用您提到的最新版本的节点安装angular cli。但它没有成功。我只使用了管理员用户

尝试了它

仅供参考 - 我刚刚在另一台机器上尝试过它也说了同样的事情 操作系统:windows7 64
节点v7.9.0
npm:v4.2.0
错误:EPERM:不允许重命名package.json

的操作
C:\Windows\system32>npm install -g @angular/cli --save
C:\Users\001091\AppData\Roaming\npm
`-- (empty)

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\@a
ngular\cli\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli" "--save"
npm ERR! node v7.9.0
npm ERR! npm  v4.2.0
npm ERR! path C:\Users\001091\AppData\Roaming\npm\node_modules\.staging\url-pars
e-e45d5bd3\package.json.1317145617
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\001091\AppData\
Roaming\npm\node_modules\.staging\url-parse-e45d5bd3\package.json.1317145617' ->
 'C:\Users\001091\AppData\Roaming\npm\node_modules\.staging\url-parse-e45d5bd3\p
ackage.json'
npm ERR!  { Error: EPERM: operation not permitted, rename 'C:\Users\001091\AppDa
ta\Roaming\npm\node_modules\.staging\url-parse-e45d5bd3\package.json.1317145617'
 -> 'C:\Users\001091\AppData\Roaming\npm\node_modules\.staging\url-parse-e45d5bd
3\package.json'
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\001091\\AppData\\Roaming\\npm\\node_modules\\.stagi
ng\\url-parse-e45d5bd3\\package.json.1317145617',
npm ERR!   dest: 'C:\\Users\\001091\\AppData\\Roaming\\npm\\node_modules\\.stagi
ng\\url-parse-e45d5bd3\\package.json',
npm ERR!   parent: '@angular/cli' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\001091\AppData\Roaming\npm-cache\_logs\2017-04-26T06_18_55
_108Z-debug.log

5 个答案:

答案 0 :(得分:2)

不幸的是,Angular CLI有时在Windows机器上存在一些问题。请查看以下主题,了解我尝试和工作过的一些可能的解决方案:https://github.com/angular/angular-cli/issues/1349

无法在C:\ Users \\ AppData \ Roaming \ npm \ node_modules

下找到.angular-cli.DELETE文件

因此我删除了整个节点模块文件夹并清除了npm缓存然后尝试了。它起作用了

答案 1 :(得分:1)

我遇到了同样的问题,所以我尝试使用node.js命令提示符而不是默认命令提示符来安装它并且它有效。

我希望它可以帮助别人。

答案 2 :(得分:0)

对我来说,问题是由在Powershell中运行npm安装引起的。在传统的命令提示符下运行修复了该问题。

答案 3 :(得分:0)

以管理员身份运行节点命令提示符为我工作。

答案 4 :(得分:0)

尝试一下(对于Mac用户)

sudo chmod -R 777 <project-directory-name>

例如

sudo chmod -R 777 webProject1