live-server 不会在 Mac BigSur 上全局安装

时间:2021-06-08 02:43:00

标签: node.js npm dependencies npm-install npm-live-server

我全新的 Mac Air 无法在全球范围内安装 live-server。不过,在我出厂重置 Mac 后,它一直抛出相同的错误。

npm ERR! errno -13
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! 
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.

我尝试在 root 上再次重新安装,但它引发了此错误

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/var/root/Library/Caches/node-gyp/14.17.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/live-server/node_modules/fsevents/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/live-server/node_modules/fsevents/.node-gyp'
gyp ERR! System Darwin 20.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/live-server/node_modules/fsevents
gyp ERR! node -v v14.17.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
+ live-server@1.2.1

如何在我的 Mac 上全局安装 live-server

1 个答案:

答案 0 :(得分:0)

看起来错误是因为脚本没有访问 /var 的权限。

您是否尝试过使用 sudo 进行安装?

sudo npm install -g live-server