首页 前端知识 npm安装依赖时报错npm error code EPERM npm error syscall mkdir npm error path D:\node-v20.16.0-x64\node_cach

npm安装依赖时报错npm error code EPERM npm error syscall mkdir npm error path D:\node-v20.16.0-x64\node_cach

2024-09-06 00:09:56 前端知识 前端哥 201 813 我要收藏

1、报错内容

npm error code EPERM
npm error syscall mkdir
npm error path D:\node-v20.16.0-x64\node_cache\_cacache
npm error errno EPERM
npm error FetchError: Invalid response body while trying to fetch https://registry.npmmirror.com/@element-plus/icons-vue: EPERM: operation not permitted, mkdir 'D:\node-v20.16.0-x64\node_cache\_cacache'
npm error     at D:\node-v20.16.0-x64\node_modules\npm\node_modules\minipass-fetch\lib\body.js:170:15
npm error     at async Response.json (D:\node-v20.16.0-x64\node_modules\npm\node_modules\minipass-fetch\lib\body.js:75:17)
npm error     at async RegistryFetcher.packument (D:\node-v20.16.0-x64\node_modules\npm\node_modules\pacote\lib\registry.js:98:25)
npm error     at async RegistryFetcher.manifest (D:\node-v20.16.0-x64\node_modules\npm\node_modules\pacote\lib\registry.js:128:23)
npm error     at async #fetchManifest (D:\node-v20.16.0-x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1199:20)
npm error     at async #nodeFromEdge (D:\node-v20.16.0-x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1037:19)
npm error     at async #buildDepStep (D:\node-v20.16.0-x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:901:11)
npm error     at async Arborist.buildIdealTree (D:\node-v20.16.0-x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:181:7)
npm error     at async Promise.all (index 1)
npm error     at async Arborist.reify (D:\node-v20.16.0-x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:131:5) {
npm error   code: 'EPERM',
npm error   errno: 'EPERM',
npm error   syscall: 'mkdir',
npm error   path: 'D:\\node-v20.16.0-x64\\node_cache\\_cacache',
npm error   type: 'system',
npm error   requiredBy: '.'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It's possible that the file was already in use (by a text editor or antivirus),
npm error or that you lack permissions to access it.
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.
npm notice
npm notice New patch version of npm available! 10.8.1 -> 10.8.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.2
npm notice To update run: npm install -g npm@10.8.2
npm notice
npm error Log files were not written due to an error writing to the directory: D:\node-v20.16.0-x64\node_cache\_logs
npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal

2、原因

没有管理员权限,无法在node_global和node_cache两个文件夹下进行一些必要的操作

3、解决

直接修改node_global和node_cache文件夹的权限:
存放全局模块(node_global)和缓存文件(node_cache)。
给这2个文件夹设置权限,右键文件夹->属性->安全tab,选择编辑,将没有打钩的位置全部打上钩(即将其它用户的权限设置为与管理员相同),应用即可。
在这里插入图片描述
在这里插入图片描述
设置新的路径:window+R+cmd 进入终端,通过npm配置命令npm config set prefix 和 npm config set cache来分别指定新的全局模块安装路径和缓存路径;说明:
prefix = 创建的node_global文件夹所在路径
cache = 创建的node_cache文件夹所在路径

npm config set prefix "D:\node-v20.16.0-x64\node_global"
npm config set cache "D:\node-v20.16.0-x64\node_cache"
转载请注明出处或者链接地址:https://www.qianduange.cn//article/17752.html
标签
评论
发布的文章

jquery video视频轮播播放

2024-09-27 09:09:58

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!