错误:EACCES:权限被拒绝,访问“/usr/local/lib/node_modules" [英] Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
本文介绍了错误:EACCES:权限被拒绝,访问“/usr/local/lib/node_modules"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么可能导致错误Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
?
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/macbookmd101/.npm/_logs/2018-02-21T16_26_08_421Z-debug.log
推荐答案
更改您的文件权限.. 像这样
change your file permissions .. like this
首先检查谁拥有目录
ls -la /usr/local/lib/node_modules
它拒绝访问,因为 node_module 文件夹归 root 所有
it is denying access because the node_module folder is owned by root
drwxr-xr-x 3 root wheel 102 Jun 24 23:24 node_modules
所以这需要通过将 root 更改为您的用户来更改,但首先运行下面的命令来检查您当前的用户 如何在 OS X 中通过命令行获取活动用户的名称?
so this needs to be changed by changing root to your user but first run command below to check your current user How do I get the name of the active user via the command line in OS X?
id -un
或
whoami
然后更改所有者
sudo chown -R [owner]:[owner] /usr/local/lib/node_modules
或
sudo chown -R ownerName: /usr/local/lib/node_modules
或
sudo chown -R $USER /usr/local/lib/node_modules
这篇关于错误:EACCES:权限被拒绝,访问“/usr/local/lib/node_modules"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文