2

I'm using stable version of node on Ubuntu 14.04. (installed via PPA) When I was trying to upgrade some packages like yo, I got the error below:

npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your version of node/npm: yo@1.4.2
npm ERR! notsup Required: {"node":">=0.10.0","npm":">=2.1.0"}
npm ERR! notsup Actual:   {"npm":"1.4.28","node":"0.10.35"}

npm ERR! System Linux 3.13.0-32-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update" "-g"
npm ERR! cwd /home/ekrem
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! code ENOTSUP
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ekrem/npm-debug.log
npm ERR! not ok code 0

When I hit (sudo) npm update -g npm, here's the result I got:

npm@2.1.3 /home/ekrem/.node/lib/node_modules/ionic/node_modules/npm

After hitting npm -v

1.4.28

I've also cleared all files under ~/.npm, cleared cache, reinstall components I needed but nothing changes. In addition;

➜  ~  which node
/usr/bin/node
➜  ~  which npm 
/usr/bin/npm
➜  ~  less ~/.npmrc
prefix = ~/.node

I've checked similar issues on the net but there's nothing close to mine.

UPDATE:

I've removed nodejs; cleared files under ~/.node & ~/.npm (as @johns has suggested) installed using first method of the instructions here. Here are updated outputs:

➜  node -v
v0.10.35
➜  npm -v 
1.4.28
➜  which node
/home/ekrem/local/bin/node
➜  which npm 
/home/ekrem/local/bin/npm
➜  npm update -g npm 
# returns nothing
➜  ~  npm config get prefix
/home/ekrem/.node
ekremkaraca
  • 1,453
  • 2
  • 18
  • 37

5 Answers5

7

I was facing a similar issue and found this post. The way I got npm to work after several tries is to remove all the npm 'node_module' folders and delete any npm config files particularly the .npmrc file in your home directory.

Then I ran 'sudo apt-get purge nodejs'.

I went to the installer and reinstalled nodejs using the following:

'curl https://npmjs.org/install.sh | sh'

then ran:

sudo apt-get install nodejs

Finally I ran:

npm update -g npm

There were issues posted about a bug in that 'update' function, but it seemed to work for me and I got from 1.4 to 2.7.

I hope this saves someone some time.

ThinkBonobo
  • 15,487
  • 9
  • 65
  • 80
5

This solution worked for me

navigate to C:\Program Files (x86)\nodejs with cmd.exe and then run the installation without -g:

npm install npm
  • Thanks but I'm using Ubuntu as I've described in the question above. – ekremkaraca Jan 19 '15 at 10:58
  • This approach does work on windows... You need to run the `cmd` prompt as an administrator and depending on your system your `nodejs` installation might be under `C:\Program Files\nodejs` instead of `C:\Program Files (x86)\nodejs` – Nirmal Patel Jan 24 '15 at 20:41
  • this worked for me on a mac, with the exception that i had to add the global flag, so i used "npm install -g npm" – Jesse Patel Jul 15 '15 at 16:57
2

In my case I had to do the following steps to go from npm@1.4.28 to npm@3.2.0 (currently the latest):

curl -L https://www.npmjs.org/install.sh | sudo sh

This line may trigger some errors like:

Error: EACCES, mkdir '/usr/lib/node_modules/npm'

If so, simply run:

sudo rm -rf /usr/lib/node_modules/npm (or the specified directory display in the error)

From there:

sudo npm install -g npm@3.0-latest

And now the

npm -v

successfully display a beautiful: 3.2.0

Cyril F
  • 1,842
  • 2
  • 19
  • 35
1

There are a lot of comments out there about "npm update -g" being broken and to not use it for now:

https://github.com/npm/npm/issues/6247

I'd trying resetting or reinstalling npm and then go from there - a fresh reinstall of npm should be relatively painless and fix things:

https://github.com/npm/npm/wiki/Troubleshooting#if-your-npm-is-broken

John Petrone
  • 26,943
  • 6
  • 63
  • 68
  • I think that discussion is about running `npm update -g` without any package name. – Ali Shakiba Jan 18 '15 at 06:44
  • @John I've already tried re-installing npm with the script on the page you gave, with sudo it says "It worked" at last but `npm -v` still returns `1.4.28`. I wish it could be still installable as seperated. – ekremkaraca Jan 18 '15 at 08:53
  • @ekremkaraca Have you taken this one step further and uninstalled via apt-get remove or apt-get purge and then re-installing? – John Petrone Jan 19 '15 at 20:49
0

Similar answer to @ThinkBonobo, but all I had to do was run the update straight from npmjs.org. From a freshly provisioned instance:

$curl -sL https://deb.nodesource.com/setup | sudo bash -
$sudo apt-get install nodejs
$npm -v
1.4.28
$curl -L https://npmjs.org/install.sh | sudo sh
$npm -v
2.7.3

No other steps were requried.

uuunk
  • 93
  • 1
  • 1
  • 7