无法安装npm i -g webpack webpack-dev-server

时间:2017-07-10 09:10:40

标签: node.js reactjs webpack webpack-dev-server npm-install

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "-g" "webpack" "webpack-dev-server"
npm ERR! node v6.11.0
npm ERR! npm  v3.10.10
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! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "-g" "webpack" "webpack-dev-server"
npm ERR! node v6.11.0
npm ERR! npm  v3.10.10
npm ERR! path npm-debug.log.1837435588
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open

npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.1837435588'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, open 'npm-debug.log.1837435588'
npm ERR!     at Error (native)
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'open',
npm ERR!   path: 'npm-debug.log.1837435588' }
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/npm-debug.log
lnkimac:Users fernando$ 

1 个答案:

答案 0 :(得分:1)

当您以全局方式安装内容时(-g),您必须以管理员权限启动npm(在大多数情况下)。

您可以通过启动具有管理员权限的命令行来实现此目的(在Windows中搜索CMD,右键单击它 - >以管理员身份启动)。

您可以再次执行该命令。这应该有用。