npm packager安装错误

时间:2012-01-19 18:41:29

标签: node.js npm

我跑了命令 -

sudo curl http://npmjs.org/install.sh | SH

但我收到此错误。有人可以帮忙吗?

Password:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
101  7881  101  7881    0     0   5165      0  0:00:01  0:00:01 --:--:--  7696
tar=/usr/bin/tar
version:
bsdtar 2.6.2 - libarchive 2.6.2
install npm@1.0
fetching: http://registry.npmjs.org/npm/-/npm-1.0.106.tgz
0.5.11-pre
1.0.106
cleanup prefix=/usr/local
All clean!
npm ERR! Could not create /usr/local/lib/node_modules/___npm.npm
npm ERR! error installing npm@1.0.106 Error: EACCESS, Permission denied '/usr/local/lib/node_modules'
npm ERR! Error: EACCESS, Permission denied '/usr/local/lib/node_modules'
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>
npm ERR! 
npm ERR! System Darwin 10.8.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/a4/a4oBVIXZEDS3kWEMo4Gh8U+++TI/-Tmp-/npm.4405/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/a4/a4oBVIXZEDS3kWEMo4Gh8U+++TI/-Tmp-/npm.4405/package
npm ERR! node -v v0.5.11-pre
npm ERR! npm -v 1.0.106
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCESS
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/a4/a4oBVIXZEDS3kWEMo4Gh8U+++TI/-Tmp-/npm.4405/package/npm-debug.log
npm not ok
It failed

3 个答案:

答案 0 :(得分:10)

他们建议不要在此网站上使用Sudo:http://howtonode.org/introduction-to-npm,而是使用:

sudo chown -R $USER /usr/local

其次是:

curl http://npmjs.org/install.sh | sh

答案 1 :(得分:5)

使用sudo

调用命令
sudo curl http://npmjs.org/install.sh | sudo sh

答案 2 :(得分:0)

以下是从源安装给定版本的步骤 注意 - 这会安装nodejs,它既可以提供节点也可以提供npm,        他们每次发布都会聚在一起。

开始新鲜删除之前的node.js和npm安装以及以下内容:

sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm   ~/.npm_ignore
sudo mv ~/tmp    ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore

安装nodejs和npm作为你自己不root用户执行这些命令(OSX / linux):

export NODE_PARENT=${HOME}/bin_0_10_32

mkdir ${NODE_PARENT}

http://nodejs.org/download/

下载源代码
cd node-v0.xxxx

./configure   --prefix=${NODE_PARENT}/nodejs

make -j8
make install   #  IMPORTANT this is NOT using sudo
               # not wanted since installing into $USER owned $NODE_PARENT

将其放入上面--prefix

定义的目录中
export PATH=${NODE_PARENT}/nodejs/bin:$PATH

定义环境变量NODE_PATH,以便节点可以找到模块的dir npm install xxx会将新安装的模块放入当前目录:

export NODE_PATH=${NODE_PARENT}/nodejs/lib/node_modules

使用语法时:npm install -g some_cool_module -g for global将它安装到dir $ NODE_PATH而不是你的$ PWD

nodejs install也为你提供了npm:

ls -la ${NODE_PARENT}/nodejs/bin

使用全局标志-g安装的后续模块将自动放入 他们的〜二进制文件〜进入上面的bin目录......比如browserify

现在把三个导出xxx = yyy 命令到〜/ .bashrc或其他一些设置,以便你的环境设置