尝试在Mac上运行"npm i -g http-server"时出错



在编程方面,我是一个完全的初学者,不知道我在做什么。我正在为本地编码训练营在 Udemy 上做一门名为"您最后的编程入门课程"的课程,我只处于设置阶段,已经遇到了这个问题。我完全遵循了每一项指示,课程上没有任何评论或信息可以帮助我弄清楚。请帮忙?(我使用的是装有最新软件的 Mac。

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
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.

我会使用ls -l /usr/local/lib/node_modules检查目录/usr/local/lib/node_modules的权限,以确保它不是由 root 拥有的。如果是,我会跑sudo chown -R <not root account>

最新更新