当我在MacOS上运行npm install -g angular-cli时,我不断收到此错误:
npm ERR! node v6.9.2 npm ERR! npm v3.10.9 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! at Error (native) npm ERR! { Error: EACCES: permission denied,access '/usr/local/lib/node_modules' npm ERR! at Error (native) 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! Please include the following file with any support request: npm ERR! /Users/apple/npm-debug.log
解决方法
当您在任何平台上使用npm install -g并获得EACCES时,您将写入您没有写入权限的目录.
有些人可能会建议使用sudo,但这会在将来导致更多问题. npm documentation提供了解决此问题的步骤.
我强烈推荐选项3,使用Homebrew安装Node.