Cannot install packages using node package manager in Ubuntu

TL;DR:

sudo apt-get install nodejs-legacy

First of all let me clarify the situation a bit. In summer 2012 Debian maintainers decided to rename Node.js executable to prevent some kind of namespace collision with another package. It was very hard decision for Debian Technical Committee, because it breaks backward compatibility.

The following is a quote from Committee resolution draft, published in Debian mailing list:

  1. The nodejs package shall be changed to provide /usr/bin/nodejs, not /usr/bin/node. The package should declare a Breaks: relationship with
    any packages in Debian that reference /usr/bin/node.

  2. The nodejs source package shall also provide a nodejs-legacy binary package at Priority: extra that contains /usr/bin/node as a symlink to
    /usr/bin/nodejs. No package in the archive may depend on or recommend
    the nodejs-legacy package, which is provided solely for upstream
    compatibility. This package declares shall also declare a Conflicts:
    relationship with the node package.

<…>

Paragraph 2 is the actual solution for OP’s issue. OP should try to install this package instead of doing symlink by hand. Here is a link to this package in Debian package index website.

It can be installed using sudo apt-get install nodejs-legacy.

I have not found any information about adopting the whole thing by NPM developers, but I think npm package will be fixed on some point and nodejs-legacy become really legacy.

Leave a Comment