nodejs npm installation error

I am doing this with root privileges. But still I am getting access denied error.

hrishikesh@hrishikesh-ubuntu:~$ sudo curl | sh
[sudo] password for hrishikesh: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
100 7881 100 7881 0 0 12574 0 --:--:-- --:--:-- --:--:-- 37174
tar=/bin/tar
version:
tar (GNU tar) 1.25
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
install npm@1.1
fetching:
0.6.10
1.1.1
cleanup prefix=/usr/local
All clean!
npm ERR! Error: EACCES, permission denied '/usr/local/bin/npm'
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR!
npm ERR! System Linux 2.6.38-13-generic
npm ERR! command "/usr/local/bin/node" "/tmp/npm.2959/package/cli.js" "rm" "npm" "-gf"
npm ERR! cwd /tmp/npm.2959/package
npm ERR! node -v v0.6.10
npm ERR! npm -v 1.1.1
npm ERR! path /usr/local/bin/npm
npm ERR! code EACCES
npm ERR! message EACCES, permission denied '/usr/local/bin/npm'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/npm.2959/package/npm-debug.log
npm not ok
npm ERR! error installing npm@1.1.1
npm ERR! error rolling back npm@1.1.1 Error: EACCES, permission denied '/usr/local/bin/npm'
npm ERR! Error: EACCES, permission denied '/usr/local/bin/npm'
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR!
npm ERR! System Linux 2.6.38-13-generic
npm ERR! command "/usr/local/bin/node" "/tmp/npm.2959/package/cli.js" "install" "-gf"
npm ERR! cwd /tmp/npm.2959/package
npm ERR! node -v v0.6.10
npm ERR! npm -v 1.1.1
npm ERR! path /usr/local/bin/npm
npm ERR! code EACCES
npm ERR! message EACCES, permission denied '/usr/local/bin/npm'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/npm.2959/package/npm-debug.log
npm not ok
It failed
hrishikesh@hrishikesh-ubuntu:~$ 

What do I do?

3 Answers

Solved it. Helped by StackOverflow. Used following command.

curl | sudo sh

My previous command

sudo curl | sh

was fetching the url with root privileges. I was supposed to do sh with root privileges.

Adding Chris Lea’s Repo

Using Launchpad repo by Chris Lea just run following commands

apt-get install python-software-properties
apt-add-repository ppa:chris-lea/node.js
apt-get update

node.js install

apt-get install nodejs

Check node.js version

node -v

Outputs

v0.10.20

npm install

Above command should install npm.

Check npm version

npm -v

Outputs

1.4.3

If for some reason, if you see npm is not installed, you may try running:

apt-get install npm

I solved this using:

curl -L | sudo sh

When I used without -L, the command does not work.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like