3

I am trying to install Node.js

Originally I tried to install it using apt-get install ....

However I later realised that these were out of date and uninstalled them using:

$ sudo apt-get --purge remove node
$ sudo apt-get --purge remove nodejs

I then followed the instructions here:

https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

which basically says to do the following:

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

I did this and it seemed to install fine! However the issue I have is the commands npm and node is not recognised! However the command nodejs is recognised.

I checked the directories /usr/local/bin and /usr/bin, but could not find node or npm. I did find nodejs though.

How do I fix this issue?

The following: dpkg-query -s nodejs

outputs this:

Package: nodejs
Status: install ok installed
Priority: extra
Section: web
Installed-Size: 2339
Maintainer: Debian Javascript Maintainers <[email protected]>
Architecture: armhf
Version: 0.6.19~dfsg1-6
Depends: libc-ares2 (>= 1.7.3), libc6 (>= 2.13-28), libev4 (>= 1:4.04), libgcc1 (>= 1:4.4.0), libssl1.0.0 (>= 1.0.1), libstdc++6 (>= 4.3.0), libv8-3.8.9.20, zlib1g (>= 1:1.1.4)
Breaks: buddycloud-server (<< 0.3.1-2), carto (<< 0.4.6+ds1-2~), coffeescript (<< 1.3.3-3~), node-bones (<< 2.0.1+ds1-3~), node-cli (<< 0.4.4~20120516-1~), node-express (<< 2.5.9-2~), node-get (<< 1.1.5+ds1-2~), node-jake (<< 0.2.32-2~), node-less (<< 1.3.0~20120310-3~), node-mapnik (<< 0.6.7-3~), node-mbtiles (<< 0.2.3-2~), node-optimist (<< 0.3.1-2~), node-semver (<< 1.0.13-2~), node-tilelive (<< 4.2.1-4~), node-uglify (<< 1.2.6-2~), node-vows (<< 0.6.3-2~), npm (<< 1.1.4~dfsg-2~)
Description: Node.js event-based server-side javascript engine
 Node.js is similar in design to and influenced by systems like
 Ruby's Event Machine or Python's Twisted.
 .
 It takes the event model a bit further - it presents the event
 loop as a language construct instead of as a library.
 .
 Node.js is bundled with several useful libraries to handle server tasks :
 System, Events, Standard I/O, Modules, Timers, Child Processes, POSIX,
 HTTP, Multipart Parsing, TCP, DNS, Assert, Path, URL, Query Strings.
Homepage: http://nodejs.org/

2 Answers 2

2

When I installed nodejs (almost exactly the same way you did, first the package then the latest version directly), I created a symbolic link in /usr/bin/node -> /usr/bin/nodejs

sudo ln -s nodejs /usr/bin/node

Eventually I moved node into ~/bin and now run it from there, since I keep multiple versions installed.

Sign up to request clarification or add additional context in comments.

2 Comments

But what about npm
npm I installed with apt-get, then refreshed with npm install -g npm, which let me pick the version to use. The global install (-g) places modules into ~/lib/node_modules and programs into ~/bin
1

dpkg-query -s nodejs will tell you if the package is installed.

If it's incorrectly installed, remove it: apt-get remove --purge nodejs

Then install it again

apt-get update;
apt-get install nodejs;

If it's correctly installed you should have the binaries for node and npm.

$ which node
/usr/bin/node

$ which npm
/usr/bin/npm

3 Comments

dpkg-query -S nodejs just shows me a list of files in user/share/doc/nodejs/... and usr/lib/nodejs and not much else. I performed the update and did sudo apt-get install nodejs, which just said nodejs is already the newest version. Both which node and which npm is empty.
sorry about that, it was -s rather than -S, I edited the response. should include a line saying: Status: install ok installed
I updated question. And yes it says install ok installed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.