3

While trying to install the less node module globally via the Node Package Manager, I ran into an interesting problem that I am having trouble solving. Basically, I am getting an error that claims the node module, less, is incompatible with my version of node. It says I am using node v0.6.12 and that it requires at least v0.8.0 to work.

First I made sure that I was using one of the latest versions of Node:

nvm use v0.10.11
Now using node v0.10.11

node -v
v0.10.11

Then I tried to install the less module globally:

sudo npm install -g less 

And got this error message:

npm ERR! error installing less@1.4.0
npm ERR! error rolling back less@1.4.0 Error: UNKNOWN, unknown error '/usr/local/lib/node_modules/less'

npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: request@2.21.0
npm ERR! Required: ["node >= 0.8.0"]
npm ERR! Actual:   {"npm":"1.1.4","node":"0.6.12"}
npm ERR! 
npm ERR! System Linux 3.2.0-45-generic
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "less"
npm ERR! cwd /home/derek
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! code ENOTSUP
npm ERR! message Unsupported
npm ERR! errno {}
npm not ok

Here you can see that the node package manager is trying to install less using (or thinks it is using) node v0.6.12. It seems as though some others have run into this problem, but his problem turned out to be that he had previously installed node via apt-get, and was resolved by him using the Node Version Manager. I initially installed Node via NVM, however.the Any help that you guys could offer would be greatly appreciated.

Note: It is worth mentioning that it will successfully install using npm install -g less, without sudo permissions. However, as soon as another terminal is opened, the less node module is removed from /usr/local/lib/node_modules, rendering it useless.

Community
  • 1
  • 1
Default
  • 16,020
  • 3
  • 24
  • 38

3 Answers3

1

Have you tired completely removing the old version, v0.6.12 with something like

sudo apt-get purge node.

I'm not a great with linux, but it seems sudo still has the old version of node in its path and calling npm under sudo is finding it and trying to use it.

ThrowsException
  • 2,586
  • 20
  • 37
1

The Node.js installed with Linux is probably installed in /usr/sbin/ (at least it was for me on Ubuntu 13.04). That's the old version. Since you have nvm installed and having that manage your Node.js versions, you'll want to point to ~/.nvm/v0.10.11/bin/node.

Jack
  • 5,264
  • 7
  • 34
  • 43
1

You already got a nodejs copy on your system. The solution is to re-install or overwrite your node using /usr/local for your prefix

git clone https://github.com/joyent/node
cd node
./configure --prefix=/usr/local
make
sudo make install

Here is a similar problem:

how to delete node on linux mint 13?

Community
  • 1
  • 1
Silom
  • 736
  • 1
  • 7
  • 20