2

I have installed nodejs via apt-get install nodejs. Works fine.

When I try to install socket.io using npm install --save socket.io I end up with failures:

npm WARN This failure might be due to the use of legacy binary "node"

I have attempted to fix this using:

sudo update-alternative --install /usr/bin/node node /usr/bin/nodesjs 10

... to no avail.

I tried to build node from source, but npm doesn't get installed - Docs say npm should be installed when building node from source.

I have downloaded the binaries from the node site and moved node and npm to /usr/local/bin. Node works fine when doing this, but npm doesn't. I always get command not found and when trying to run npm using the absolute path: /usr/local/bin/npm it's not found (permissions were correct).

If I run: node -v I get v0.10.29 which is the same as running 'nodejs -v'.

So, I am left in the dark not knowing what to do next.

Any advice please?

1
  • Make sure you are using sudo. Can you add the whole error?
    – Drazisil
    Commented Nov 19, 2015 at 14:33

2 Answers 2

2

You should remove the old version with:

apt-get remove nodejs nodejs-legacy npm

And try to install again.

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get -y install nodejs

To compile and install native addons from npm you may also need to install build tools:

sudo apt-get install -y build-essential
0

If you manually moved npm into /usr/local/bin you should write this command to your cli and try again.

alias npm="/usr/local/bin/npm"  
1
  • /usr/local/bin is in the $PATH would I still need to do this? Other software I've installed to the same directory do not require this. Commented Nov 19, 2015 at 14:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.