在 OSX 上安装 Yeoman

Install Yeoman on OSX

我在 OSX 上使用 ASP.NET 5 设置 Visual Studio 代码,但在安装 Yeoman 时出现错误。我正在使用以下命令。

npm install -g yo grunt-cli generator-aspnet bower

并出现这些错误

npm ERR! tar.unpack untar error /Users/username/.npm/grunt-cli/0.1.13/package.tgz
npm ERR! tar.unpack untar error /Users/username/.npm/generator-aspnet/0.0.60/package.tgz
npm ERR! tar.unpack untar error /Users/username/.npm/yo/1.4.7/package.tgz
npm ERR! Darwin 14.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "yo" "grunt-cli" "generator-aspnet" "bower"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path /usr/local/lib/node_modules/grunt-cli
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/grunt-cli'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/grunt-cli']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/grunt-cli',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/grunt-cli',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR!      'FSReqWrap.oncomplete (fs.js:95:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, rmdir '/usr/local/lib/node_modules/bower'
npm ERR! error rolling back     at Error (native)
npm ERR! error rolling back  { [Error: EACCES, rmdir '/usr/local/lib/node_modules/bower']
npm ERR! error rolling back   errno: -13,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/bower' }

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/username/npm-debug.log

如何在没有这些错误的情况下回滚和安装

您需要 root 权限或权限才能进行全局安装!

试试这个:

sudo npm install -g yo grunt-cli generator-aspnet bower