无法通过nvm(本地配置文件,而不是sudo)安装软件包-g

时间:2015-05-06 10:19:07

标签: node.js bower

我正在使用nvm运行节点版本0.12.2。

我尝试全球安装bower:

karl@karl-laptop:~/www/busarama/src$ npm install -g bower
npm ERR! tar.unpack untar error /home/karl/.npm/bower/1.4.1/package.tgz
npm ERR! Linux 3.16.0-36-generic
npm ERR! argv "/home/karl/.nvm/versions/node/v0.12.2/bin/node" "/home/karl/.nvm/versions/node/v0.12.2/bin/npm" "install" "-g" "bower"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/bower',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/home/karl/.nvm/versions/node/v0.12.2/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23',
npm ERR!      '/home/karl/.nvm/versions/node/v0.12.2/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR!      'FSReqWrap.oncomplete (fs.js:95:15)' ] }
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!     /home/karl/www/busarama/src/npm-debug.log

我非常怀疑是因为我今天早些时候这样做了:

npm config set prefix /usr/local

有谁知道默认的npm配置前缀应该是什么(当安装-g到本地配置文件,而不是sudo)?我安装了nvm作为本地用户。

这影响了我尝试全局安装的所有内容。

找到这个小小的好链接:https://docs.npmjs.com/files/folders

Local install (default): puts stuff in ./node_modules of the current package root.
Global install (with -g): puts stuff in /usr/local or wherever node is installed.
Install it locally if you're going to require() it.
Install it globally if you're going to run it on the command line.
If you need both, then install it in both places, or use npm link.
  • ...或安装节点的任何地方。

这意味着我猜它应该安装到某个地方的/home/karl/.nvm/versions/node/v0.12.2

我需要将npm config前缀设置为正在运行的节点。

1 个答案:

答案 0 :(得分:0)

我刚刚重新安装了nvm。似乎修复了配置文件。