0

我的全新 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

如何live-server在全球范围内实际安装在我的 Mac 上?

4

1 回答 1

0

看起来错误是由于脚本没有访问权限而引起的/var

你试过安装sudo吗?

sudo npm install -g live-server
于 2021-06-08T04:55:53.250 回答