Ashish
Ashish

Reputation: 851

npm packager installation errors

I ran the command -

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

But I am getting this Error. Can anyone help?

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 [email protected]
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 [email protected] 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!     <[email protected]>
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

Upvotes: 3

Views: 7193

Answers (3)

Scott Stensland
Scott Stensland

Reputation: 28305

Below are the steps to install a given release from source NOTE - this installs nodejs which gives you both node as well as npm, they come together per release.

to start fresh remove prior node.js and npm installs as well as these :

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

to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :

export NODE_PARENT=${HOME}/bin_0_10_32

mkdir ${NODE_PARENT}

download source from : 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

which puts it into dir defined by above --prefix

export PATH=${NODE_PARENT}/nodejs/bin:$PATH

define environment variable NODE_PATH so node can find dir for modules otherwise npm install xxx will put newly installed module into current dir :

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

when you use syntax : npm install -g some_cool_module the -g for global installs it into dir $NODE_PATH and not your $PWD

nodejs install gives you npm as well :

ls -la ${NODE_PARENT}/nodejs/bin

Subsequent modules you install using global flag -g will automagically put their ~binaries~ into above bin dir ... like browserify

Now put above three export xxx=yyy commands into your ~/.bashrc or some such so your environment is setup

Upvotes: 0

zallarak
zallarak

Reputation: 5525

They recommend to not use Sudo on this site: http://howtonode.org/introduction-to-npm, and to instead use:

sudo chown -R $USER /usr/local

Followed by:

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

Upvotes: 10

Jatin Ganhotra
Jatin Ganhotra

Reputation: 7035

Call the command using sudo:

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

Upvotes: 5

Related Questions