PS D:\***> npm install -g create-vue
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\***\node_cache\_cacache\tmp\3acf1f0a
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'D:\***\node_cache\_cacache\tmp\3acf1f0a'
npm ERR! [Error: EPERM: operation not permitted, open 'D:\***\node_cache\_cacache\tmp\3acf1f0a'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'D:\\***\\node_cache\\_cacache\\tmp\\3acf1f0a'
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: D:\***\node_cache\_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
处理办法
win
1、使用管理员身份运行cmd(不推荐)
每次安装包,都要以管理员身份运行cmd,有点麻烦
2、删除npmrc文件(不推荐)
如果自己本身就是管理员权限,因而无用
3、需要删除npmrc文件。
强调:不是nodejs安装目录npm模块下的那个npmrc文件
而是在C:\Users\用户名下的.npmrc文件
4、清除缓存(没成功)
用命令清除缓存的,我自己试了下没成功,放弃(都没成功,说什么放弃),上面删除文件起码成功了。
cmd中运行npm cache clean --force
5、更改文件夹权限(推荐)
每次安装都要用管理员身份运行,主要因为安装nodejs时没有授予写的权限,找到nodejs安装文件夹更改权限即可。
右键nodejs安装文件夹>>>属性>>>安全>>>编辑>>>选择用户>>>勾选写入权限>>>应用
Linux
1、直接在前面加sudo
sudo npm install <包>