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的问题,删掉即可。
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!