npm install 总是报错(Mac OS环境下)
mac使用npm安装hexo,输入命令:
npm install -g hexo-cli
报错如下:
npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/wangmaster/.nvm/versions/node/v4.4.2/bin/node" "/Users/wangmaster/.nvm/versions/node/v4.4.2/bin/npm" "install" "-g" "hexo-cli"
npm ERR! node v4.4.2
npm ERR! npm v2.15.0
npm ERR! path /Users/wangmaster/.nvm/versions/node/v4.4.2/lib/node_modules/hexo-cli/.editorconfig
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall unlink
npm ERR! Error: EACCES: permission denied, unlink '/Users/wangmaster/.nvm/versions/node/v4.4.2/lib/node_modules/hexo-cli/.editorconfig'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, unlink '/Users/wangmaster/.nvm/versions/node/v4.4.2/lib/node_modules/hexo-cli/.editorconfig']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'unlink',
npm ERR! path: '/Users/wangmaster/.nvm/versions/node/v4.4.2/lib/node_modules/hexo-cli/.editorconfig' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES: permission denied, unlink '/Users/wangmaster/.nvm/versions/node/v4.4.2/lib/node_modules/hexo-cli/.editorconfig'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES: permission denied, unlink '/Users/wangmaster/.nvm/versions/node/v4.4.2/lib/node_modules/hexo-cli/.editorconfig']
npm ERR! error rolling back errno: -13,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back syscall: 'unlink',
npm ERR! error rolling back path: '/Users/wangmaster/.nvm/versions/node/v4.4.2/lib/node_modules/hexo-cli/.editorconfig' }
npm ERR! Please include the following file with any support request:
npm ERR! /Users/wangmaster/Desktop/Blog/npm-debug.log
解决方案:
- 加上sudo执行:
即:
sudo npm install -g hexo-cli
按回车,输入机器密码即可。