我现在在尝试运行npm i
时遇到了这个问题:
npm i
npm ERR! path /home/ole/.npm/_cacache/index-v5/37/b4
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/home/ole/.npm/_cacache/index-v5/37/b4'
npm ERR! [OperationalError: EACCES: permission denied, mkdir '/home/ole/.npm/_cacache/index-v5/37/b4'] {
npm ERR! cause: [Error: EACCES: permission denied, mkdir '/home/ole/.npm/_cacache/index-v5/37/b4'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/home/ole/.npm/_cacache/index-v5/37/b4'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! stack: 'Error: EACCES: permission denied, mkdir ' +
npm ERR! "'/home/ole/.npm/_cacache/index-v5/37/b4'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/home/ole/.npm/_cacache/index-v5/37/b4',
npm ERR! parent: 'config-chain'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
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 (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ole/.npm/_logs/2019-05-14T21_15_39_992Z-debug.log
我尝试更改文件的所有权和权限,并删除项目目录中的node_modules
,但这些步骤均无效。有想法吗?
答案 0 :(得分:1)
使用sudo安装全局软件包会留下所有权错误的文件。
运行简短版本以修复所有权,然后再次尝试安装:
sudo chown -R $(whoami) ~/.npm