我曾尝试在npm的帮助下全局安装cowsay包,但遇到以下错误。
npm i -g考赛
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/cowsay
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/cowsay'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/cowsay'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/cowsay'
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.
2条答案
按热度按时间toe950271#
要获取目录及其所有者的列表:
找到npm安装到的文件夹,更改用户的所有权权限。您可以通过以下方法完成此操作:
这会将给定文件夹的所有者权限更改为您的用户。现在npm应该可以安装了。
jrcvhitl2#
粘贴以下命令并运行:
然后运行原始命令: