解决执行npm i 报错 operation not permitted

前提:

最新开发后台管理系统,从公司gitlab上下载最新的admin代码:

运行npm i 报错 operation not permitted

E:\webview\admin>npm i
npm WARN tarball tarball data for ng-zorro-antd@1.6.0 (sha512-qZz/7X/ihi8Cyn/rXYRAooloLnVxkP4SivA1QErSaigJ0VqRKsKVSh/P+CngMkgX9kmYTm5TVcC9awrIWznw3A==) seems to be corrupted. Trying one more time.
npm ERR! path E:\webview\admin\node_modules\.staging\ng-zorro-antd-b6616503\esm2015\pagination\nz-pagination.component.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'E:\webview\admin\node_modules\.staging\ng-zorro-antd-b6616503\esm2015\pagination\nz-pagination.component.js'
npm ERR!  { [Error: EPERM: operation not permitted, unlink 'E:\webview\admin\node_modules\.staging\ng-zorro-antd-b6616503\esm2015\pagination\nz-pagination.component.js']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'E:\webview\admin\node_modules\.staging\ng-zorro-antd-b6616503\esm2015\pagination\nz-pagination.component.js'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path:
npm ERR!       'E:\\webview\\admin\\node_modules\\.staging\\ng-zorro-antd-b6616503\\esm2015\\pagination\\nz-pagination.component.js' },
npm ERR!   stack:
npm ERR!    "Error: EPERM: operation not permitted, unlink 'E:\\webview\\admin\\node_modules\\.staging\\ng-zorro-antd-b6616503\\esm2015\\pagination\\nz-pagination.component.js'",
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path:
npm ERR!    'E:\\webview\\admin\\node_modules\\.staging\\ng-zorro-antd-b6616503\\esm2015\\pagination\\nz-pagination.component.js',
npm ERR!   parent: 'admin' }
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\Administrator\AppData\Roaming\npm-cache\_logs\2020-12-15T08_01_27_643Z-debug.log

我们看这个提示,(operation not permitted) 操作没有授权

也就是刚从sourceTree下载下来的文件夹 需要赋权限,

于是我进入到文件夹点击文件夹的右键查看属性

如图:

点击编辑->设置当前用户的权限

设置好之后 点击应用->确定

在整个过程中最好不要用vsCode打开这个文件夹,因为有的文件会因为vscode的权限不够导致没有设置好权限。

操作之前记得勾上应用到子文件夹。

然后右键该文件夹->管理员获得所有权。

最后运行

npm i

运行结果如下:


> @angular/cli@6.0.8 postinstall E:\webview\admin\node_modules\@angular\cli
> node ./bin/ng-update-message.js

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.9.3 (node_modules\node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.9.3 postinstall: `node scripts/build.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

added 1115 packages from 1288 contributors in 394.155s

E:\webview\admin>\

表示安装成功了。

如果有更好的办法欢迎留言评论,谢谢

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值