npm下载依赖报错

npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path E:\code\20200212\web\cbos2.0-wenlv-wx-cli\node_modules\.staging\caniuse-lite-70323fe6\data\features\document-scrollingelement.js
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'E:\code\20200212\web\cbos2.0-wenlv-wx-cli\node_modules\.staging\caniuse-lite-70323fe6\data\features\document-scrollingelement.js'
npm ERR!  [OperationalError: EPERM: operation not permitted, unlink 'E:\code\20200212\web\cbos2.0-wenlv-wx-cli\node_modules\.staging\caniuse-lite-70323fe6\data\features\document-scrollingelement.js'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, unlink 'E:\code\20200212\web\cbos2.0-wenlv-wx-cli\node_modules\.staging\caniuse-lite-70323fe6\data\features\document-scrollingelement.js'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'unlink',
npm ERR!     path: 'E:\\code\\20200212\\web\\cbos2.0-wenlv-wx-cli\\node_modules\\.staging\\caniuse-lite-70323fe6\\data\\features\\document-scrollingelement.js'
npm ERR!   },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'E:\\code\\20200212\\web\\cbos2.0-wenlv-wx-cli\\node_modules\\.staging\\caniuse-lite-70323fe6\\data\\features\\document-scrollingelement.js',
npm ERR!   parent: 'cbos2.0-wenlv-wx-cli'
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!     D:\nodejs\node_cache\_logs\2021-11-25T08_55_03_606Z-debug.log

之前NPM 安装一直报这个,以为还真是权限不够,感觉有点奇怪,用管理员权限执行,没用,不过后面查了下,以为是 缓存的问题,清理下缓存就行,不用管理员权限。但没用(如下)

方法1、

需要删除npmrc文件。

强调:不是nodejs安装目录npm模块下的那个npmrc文件,而是在C:\Users{账户}\下的.npmrc文件…,在删掉依赖重新下载

方法2、

或者直接用命令清理就行,控制台输入:

npm cache clean --force

觉得是因为之前 下载了CNPM ,所以导致了 权限问题。以后包用 cmpn 安装 就解决问题了

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐