The operation was rejected by your operating system. npm ERR! It‘s possible that the file was alrea

在Win10系统中尝试安装node.js时遇到EPERM权限错误,问题可能出在文件已被占用或权限不足。解决方法包括创建node_global和node_cache文件夹,配置npm的全局路径和缓存路径,以及以管理员权限运行PowerShell。
摘要由CSDN通过智能技术生成

在win10系统下安装node.js出现了如下的报错。

C:\Users\lenovo>npm install -g vue
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path F:\node\node_cache\_cacache\index-v5\4b\d5\ac02d8eac51f5c368b18a948d14b7ba882d43e6f4cafddbf9dda740d2afa
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'F:\node\node_cache\_cacache\index-v5\4b\d5\ac02d8eac51f5c368b18a948d14b7ba882d43e6f4cafddbf9dda740d2afa'
npm ERR!  [Error: EPERM: operation not permitted, open 'F:\node\node_cache\_cacache\index-v5\4b\d5\ac02d8eac51f5c368b18a948d14b7ba882d43e6f4cafddbf9dda740d2afa'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: 'F:\\node\\node_cache\\_cacache\\index-v5\\4b\\d5\\ac02d8eac51f5c368b18a948d14b7ba882d43e6f4cafddbf9dda740d2afa',
npm ERR!   requiredBy: '.'
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! Log files were not written due to an error writing to the directory: F:\node\node_cache\_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal

首先需要在安装node.js文件夹中自行创立这两个文件夹,node_global代表全局变量的文件夹,node_cache代表缓存的文件夹。
接下来要配置文件:

npm config set prefix "D:\Coding_tools\Nodejs\node_global"
npm config set cache "D:\Coding_tools\Nodejs\node_cache"

这里换成自己的路径即可。
接下来就是配置环境变量:
在这里插入图片描述
在这里插入图片描述然后将用户变量中Path,关于node的环境变量改为目前的全局变量地址。

在这里插入图片描述这样就可以了,但是当我们再到cmd窗口去进行npm下载时就会报错
报错的内容说是权限不够,不能新建_cacache,这表示目前的权限不够,所以需要换管理员模式的powershell,与我之前用的管理员模式的cmd不太相同,仅供参考:
在搜索窗口上输入powershell,选择run as Administrator即可
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值