安装Karma时出错(Testacular)

时间:2013-04-12 19:29:18

标签: node.js npm karma-runner

我的机器上运行的节点版本为v0.8.18,我正在尝试安装Karma(Testacular)但是仍然遇到以下错误。我无法理解错误,有没有人碰到这个或知道缺少什么?

ruby-2.0.0-p0 AngularTut marty$ npm install -g karma
npm http GET https://registry.npmjs.org/karma
npm http 304 https://registry.npmjs.org/karma
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/karma'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/karma']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/karma',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/karma',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ 'DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:297:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "karma"
npm ERR! cwd /Users/marty/Web/AngularTut
npm ERR! node -v v0.8.18
npm ERR! npm -v 1.2.2
npm ERR! path /usr/local/lib/node_modules/karma
npm ERR! fstream_path /usr/local/lib/node_modules/karma
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/karma'
npm ERR! fstream_stack DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:297:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/marty/Web/AngularTut/npm-debug.log
npm ERR! not ok code 0

1 个答案:

答案 0 :(得分:11)

在命令前添加sudo

sudo npm install -g karma