Reputation: 3953
So, I'm working on a mac and as webserver, I got Debian 8 installed. However, I'm currently working on a node application which I developed on my localhost most of the time, where everything works fine - I can use node index.js
without issues.
However, I installed node on my webserver via the recommendation of the node.js website, which is ...
sudo apt-get install -y nodejs
... which didn't throw any errors. After that, I could use the npm command. But when I try to execute node index.js
, I receive bash: node: command not found
. Also, node is not installed in my /usr/local/bin
folder. So I can't even run in via /usr/local/bin/node
which was recommended here.
So what exactly did I do wrong? I'm rather confused right now and really don't know how to fix the problem.
Upvotes: 11
Views: 19062
Reputation: 323
My problem was that I didn't load the distributions repo...
for the curl url, you'll need to change your setup_#.x number based on your version of Debian.
Adding the NodeSource APT repository for Debian-based distributions repository AND the PGP key for verifying packages
$ sudo curl -sL https://deb.nodesource.com/setup_6.x | bash -
Install Node.js from the Debian-based distributions repository
$ sudo apt-get install -y nodejs
Hope this helps!
More information here... http://nodesource.com/blog/installing-node-js-tutorial-debian-linux/
Upvotes: 0
Reputation: 201
I just installed node on raspian (Debian for Raspberry Pi) and had the same problem. The command nodejs worked for me though.
Upvotes: 0
Reputation: 11
Go to the official Node.js download page and download either the 32-bit or 64-bit Linux binary file, depending on your system type.
You can determine the CPU architecture of your server with these commands:
$ getconf LONG_BIT
64
$ uname -p
x86_64
You can download this file from the browser or from the console. The latter is shown below (Note: the specific Node.js version might be different for you):
$ wget https://nodejs.org/dist/v4.2.2/node-v4.2.2-linux-x64.tar.gz
**Change node version **
From a console window, go to the directory to which the Node.js binary was downloaded, and then execute the following command to install the Node.js binary package in “/usr/local/”:
$ sudo tar -C /usr/local --strip-components 1 -xzf node-v4.2.2-linux-x64.tar.gz
You should now have both node and npm installed in “/usr/local/bin”. You can check this typing:
$ ls -l /usr/local/bin/node
$ ls -l /usr/local/bin/npm
Check node version
$ node -v
$ npm -v
Upvotes: 1
Reputation: 17711
Did you previously install node
package, too? If so, try:
$ sudo apt-get --purge remove node
$ sudo apt-get --purge remove nodejs
$ sudo apt-get install -y nodejs-legacy
# check
$ node --version
v4.0.0
See also this answer
Upvotes: 18