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

C:Userslenovo>npm install -g vue
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path F:nodenode_cache_cacacheindex-v54bd5ac02d8eac51f5c368b18a948d14b7ba882d43e6f4cafddbf9dda740d2afa
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'F:nodenode_cache_cacacheindex-v54bd5ac02d8eac51f5c368b18a948d14b7ba882d43e6f4cafddbf9dda740d2afa'
npm ERR!  [Error: EPERM: operation not permitted, open 'F:nodenode_cache_cacacheindex-v54bd5ac02d8eac51f5c368b18a948d14b7ba882d43e6f4cafddbf9dda740d2afa'] {
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:nodenode_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_toolsNodejsnode_global"
npm config set cache "D:Coding_toolsNodejsnode_cache"

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

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

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注