欧阳简之 > npm install提示operation not permitted, unlink xxx

热爱代码,对每一行代码保持一颗敬畏之心。

执行 npm install -g cnpm --registry=https://registry.npm.taobao.org 时报了如下错误

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this
npm WARN tarball tarball data for smart-buffer@^4.1.0 (sha1-kWBcJdkWUvRmHqacz0XxszHKIbo=) seems to be corrupted. Trying one more time.
npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path C:\Users\503ou\AppData\Roaming\npm\node_modules\.staging\smart-buffer-c43448cb\package.json
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\503ou\AppData\Roaming\npm\node_modules\.staging\smart-buffer-c43448cb\package.json'
npm ERR!  [OperationalError: EPERM: operation not permitted, unlink 'C:\Users\503ou\AppData\Roaming\npm\node_modules\.staging\smart-buffer-c43448cb\package.json'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, unlink 'C:\Users\503ou\AppData\Roaming\npm\node_modules\.staging\smart-buffer-c43448cb\package.json'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'unlink',
npm ERR!     path: 'C:\\Users\\503ou\\AppData\\Roaming\\npm\\node_modules\\.staging\\smart-buffer-c43448cb\\package.json'
npm ERR!   },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\\Users\\503ou\\AppData\\Roaming\\npm\\node_modules\\.staging\\smart-buffer-c43448cb\\package.json',
npm ERR!   parent: 'cnpm'
npm ERR! }
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\503ou\AppData\Roaming\npm-cache\_logs\2020-08-16T04_24_29_235Z-debug.log

解决办法:

检查IDE是否打开了这个项目,可以关闭IDE重试。

tagged by npm cnpm qianduan