First following link couldn't install npm on ubuntu, I installed nodejs successfully, but then when I install npm, it gives error :

The following packages have unmet dependencies:
**npm : Depends: node-gyp (>= 0.10.9) but it is not going to be installed**
E: Unable to correct problems, you have held broken packages.
root@yatin-3000-N200:/home/yatin/Documents/installations# npm install
The program 'npm' is currently not installed. You can install it by typing:
apt-get install npm*

Also tell if there is some command from which dependencies also get installed automatically in Ubuntu without we caring for it.

  • The install command for npm is : sudo apt update && sudo apt install npm – Knud Larsen Jul 16 '16 at 12:47

Yeah!! I got answer at askUbuntu by lot of searching and struggle. First we need to install g++-4.8 which right way is given at https://stackoverflow.com/questions/19836858/upgrade-gcc-4-6-3-on-ubuntu-12-04-to-4-8-2 ,answer by JintoThomas, and then we can install nodejs following at Ubuntu / Install NodeJS & npm , answer by Anton Dozortsev. And Thanks Parto but i tried it before, that not work for me. Then install less compiler(not for nodejs but if required) as

npm install -g less

Then final step is: Because the command name of the node.js is nodejs (instead of node) on Ubuntu, when the installation is complete, you need to change this first line of lessc command. Open /usr/local/bin/lessc with your favorite text editor (with root privileges), and change the end of the first line from node to nodejs.

-#!/usr/bin/env node
+#!/usr/bin/env nodejs

'-' means in above remove it and '+' means add it

It may be possible that lessc is at some other localtion, check it by

which lessc

like for me it is at /usr/bin/lessc

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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