node: command not found
Solution 1
The node
package is unrelated to NodeJS. See here for information about node :
Amateur Packet Radio Node program (transitional package)
You should instead install the nodejs
package.
sudo apt-get install nodejs
then use it with the nodejs
command.
The reason node
doesn't work is likely because of conflicts with the original node
package linked above.
If you want npm
, you'll have to install that as well.
sudo apt-get install npm
Solution 2
I agree, this is a bit of an issue but I don't know why it's happening.
The Fix
First things first, just create a symbolic link from called node
pointing to the nodejs
binary.
ln -s /usr/bin/nodejs /usr/bin/node
The Problem
Quite a few guides I found for installing Nodejs (here and here) all have similar code to test whether the installation happened correctly. So essentially create a simple server like so:
// hello_node.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.js\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
and then run it in nodejs with the following:
node hello_node.js
And then when I was trying to use npm to install something, it was failing and reporting the same node not found
message.
Solution 3
Like @minerz029 already said there is a conflict with the node
package. But if you still need the node
command (because a script uses only node
for example), the correct way is to install the nodejs-legacy
package:
apt-get install nodejs-legacy
and not create a symlink on your own (especially not in /usr/bin/
). This will provide a node
command for nodejs.
Solution 4
Try this
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
:)
Solution 5
may you need to install manually
sudo apt-get install npm
Related videos on Youtube
Matthieu Napoli
I am a software engineer passionate about code and human interactions around it. I like to work with great people, learn and get things done. You can read more about me on my blog or on my GitHub profile. Here are some projects I'm working on: bref.sh: deploy PHP on AWS Lambda to create serverless applications PHP-DI - Dependency injection library for PHP externals.io @matthieunapoli
Updated on September 18, 2022Comments
-
Matthieu Napoli almost 2 years
I don't understand why the
node
command will not work, whereasnodejs
works:$ node --version zsh: command not found: node $ nodejs --version v0.10.15
I tried
apt-get install nodejs
, but the latest version is already installed.And furthermore:
$ npm zsh: command not found: npm
I thought
npm
was included in NodeJS > 0.10?-
Matthieu Napoli over 10 years@AhmedAl-battashi It doesn't help, I have already read it. NodeJS is installed,
nodejs
is in the PATH, butnode
andnpm
aren't available, I can't find them anywhere on my system. -
yjwong over 10 yearsI'm not entirely sure, but I do recall that the reason why the
node
binary was renamed was because it conflicted with one of the packages callednode
(Amateur Packet Radio Node Program). -
Braiam over 10 yearsAre you sure that you are looking for
node
and notnodejs
?node
is not what you think it is. -
Matthieu Napoli over 10 years@Braiam
node
is used in every tutorial I've seen -
binki about 7 yearsIt looks like the
node
package in Ubuntu will be renamed toax25-node
. So hopefully in the future Ubuntu will just install a binary namednode
when you installnodejs
. @Braiam The de-facto standard shebang for node.js scripts is#!/usr/bin/env node
, so Ubuntu sort of breaks standard node.js scripts because of its binary name conflict policy which was not respected by the node.js project.
-
-
Matthieu Napoli over 10 yearsI read everywhere that I shouldn't install npm manually because it was included in > v0.10 :/ I'm a little lost
-
Matthieu Napoli over 10 yearsI knew about the
node
package, however I don't see why a name package has any influence on the command line tool. For example, I don't installphp
, butphp5-cli
. But thanks for the answer, I was unsure if manually installingnpm
would be a problem, apparently it is not. -
Simón over 8 yearsFunny tip: there is a nodejs-legacy package that provides the symlink, purportedly for compatibility with "legacy code" that still relies on it.
-
grooveplex about 8 yearsInstalling the
nodejs-legacy
package lets you use eithernode
ornodejs
. -
grooveplex about 8 years@Simón I think it's a better solution than making a symbolic link.
-
Shawn Xie about 8 yearsIt works. I think this is better than @jlouzado's answer.
-
karel almost 7 yearsWhy are you not installing the latest version?:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
-
MUHASIN BABU almost 7 yearssetup_6.x is stable
-
karel almost 7 yearsThe LTS policy for Node.js version 8 is that it is pending LTS now, it starts being LTS in a few months in October, 2017, it starts maintenance period in April, 2019, and ends maintenance in December, 2019. For more information see the table in this answer: askubuntu.com/questions/626383/…
-
some bits flipped over 6 yearsunless you frequently "start from scratch" with your OS install .... MUCH better to let apt manage symlinks in bin. Thanks!
-
sudo about 6 yearsSo now I'm counting 3 packages I have to install if I'm doing basically anything with Node.js. I've been trying to install this one Node.js library for like an hour.
-
Vinayak over 5 yearsI was unable to install
asciicast2gif
because during installation it runsnode install.js
and I get the errorsh: 1: node: not found
. This fixes it.