Angular CLI 安装时报syscall unlink错误解决方法

前提:已经完成了node js 的安装。
步骤:
按照网上的命令打开cmd直接执行以下命令:

 npm install -g @angular/cli

由于node-sass包被墙,可能会安装报错,此时执行以下语句:

npm install cnpm -g --registry=https://registry.npm.taobao.org

安装淘宝cnpm时,系统报错:

npm WARN deprecated socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
npm WARN tarball tarball data for moment@^2.18.1 (sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=) seems to be corrupted. Trying one more time.
npm ERR! path C:\Users\zhangjixun01\AppData\Roaming\npm\node_modules\.staging\moment-78cea585\min\locales.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\zhangjixun01\AppData\Roaming\npm\node_modules\.staging\moment-78cea585\min\locales.js'
npm ERR!  { [Error: EPERM: operation not permitted, unlink 'C:\Users\zhangjixun01\AppData\Roaming\npm\node_modules\.staging\moment-78cea585\min\locales.js']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'C:\Users\zhangjixun01\AppData\Roaming\npm\node_modules\.staging\moment-78cea585\min\locales.js'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path:
npm ERR!       'C:\\Users\\zhangjixun01\\AppData\\Roaming\\npm\\node_modules\\.staging\\moment-78cea585\\min\\locales.js' },
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, unlink \'C:\\Users\\zhangjixun01\\AppData\\Roaming\\npm\\node_modules\\.staging\\moment-78cea585\\min\\locales.js\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path:
npm ERR!    'C:\\Users\\zhangjixun01\\AppData\\Roaming\\npm\\node_modules\\.staging\\moment-78cea585\\min\\locales.js',
npm ERR!   parent: 'cnpm' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\zhangjixun01\AppData\Roaming\npm-cache\_logs\2018-08-06T07_00_55_009Z-debug.log

说是权限问题,但我权限都放开了试了一遍也不行,又换了以下方法安装:
1.安装node-sass包:

set SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/

npm install node-sass

2.然后再直接安装angular:

npm install -g @angular/cli

此时成功!运行ng -v命令后:

>ng -v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.1.2
Node: 10.8.0
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.7.2
@angular-devkit/core         0.7.2
@angular-devkit/schematics   0.7.2
@schematics/angular          0.7.2
@schematics/update           0.7.2
rxjs                         6.2.2
typescript                   2.7.2

可以继续接下来的创建新项目了。
(楼主小白,请大家多多指教,笔芯)

更新:翻了外网,发现有老外指出是AppData\Roaming下的两个包
npm
npm-cache的问题,删掉即可。
这里写图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值