Checking version of node returns nothing [duplicate] - linux

This question already has answers here:
nodejs is already the newest version but "node -v" doesn't give a response
(3 answers)
Closed 8 years ago.
I am working on linux(ubuntu 64bit), and I have installed node using the tutorial: http://howtonode.org/how-to-install-nodejs.
Here, now when I am doing node --version, it shows the following output.
abhinav#abhinav:~/node$ node --version
abhinav#abhinav:~/node$ node
abhinav#abhinav:~/node$ node -v
As visible, it does not print anything. What could be the reason for this. Please help?

Try
abhinav#abhinav:~/node$ nodejs --version

Using nodejs -v or nodejs --version will serve your purpose, hopefully. In some cases, executable of node is mapped to nodejs.

You should check your $PATH variables. Simply type $PATH in the console and examine the output. If /usr/local/bin/node isn't there (and its probably not) add to .bashrc (hidden in home folder) or .profile:
export PATH="/usr/local/bin/node"
This will tell bash where to look for the node binary.

You can install Node.js by:
sudo apt-get install nodejs nodejs-dev npm
You can check the version by:
nodejs --version

Related

How to install node.js

I did the following:
user#machine:~$ sudo n stable
installed : v12.13.0 (with npm 6.12.0)
user#machine:~$ node --version
v8.10.0
user#machine:~$ which node
/usr/local/bin/node
user#machine:~$ /usr/local/bin/node --version
v12.13.0
I was expecting v12.13.0 to be installed, but node --version reveals v8.10.0.
What did I do wrong? How do I get v12.13.0 installed? FYI I am on Jetson Nano and I'm really just trying to get LTS Nodejs installed and don't know how.
BTW, if I do sudo apt-get install nodejs I only get v8.10.0.
MORE INFO:
user#machine:~$ node --version
v8.10.0
user#machine:~$ sudo node --version
v12.13.0
Seems sudo is affecting this somehow?
(I'm not very familiar with linux, but I'm learning ... sorry if I'm missing "obvious" stuff.)
I worked around the problem by forgoing the use of n.
Here's how to install directly from the dist at nodejs.org.
wget https://nodejs.org/dist/v12.10.0/node-v12.13.0-linux-arm64.tar.gz
sudo tar -xf node-v12.13.0-linux-arm64.tar.gz --directory /usr/local --strip-components 1
Can't comment but try replacing /usr/bin/node with a symbolic link to /usr/local/bin/node. Had similar issue some time ago that ate my brain. Solved it like this.
P.S don't forget to backup
It's very strange...
Could you try something?
mv /usr/local/bin/node /usr/local/bin/node.back
which node
mv /usr/local/bin/node.back /usr/local/bin/node
I just want to see what produce which if you remove the old node version binary.
Also provide more info about file /usr/local/bin/node, is it a symbolic link? If true, to what?
1) Try opening a new shell and checking what version of node you see there.
n installs the node binary by default to /usr/local/bin/node. You may already have had a node binary installed to /usr/bin/node, and your shell cache of known commands (paths) may be running the old one.
Example of problem with bash: https://github.com/tj/n/issues/588
2) If your OS has the command, you can run which -a node to see if you have multiple versions and where they are installed. (Uninstalling the ones you don't want reduces potential for confusion.)
3) Check the location of the intended version is in your PATH. If you are using n, try running n doctor. There are some extra checks that the version of node found is the one that is the one that n installed.

Installing Node.js - No such file or direktory

I have removed node.js on my CentOS. After that I was installing a new version node.js. Now I can't run the node.js:
-bash: /usr/local/bin/node: No such file or direktory
The only solution is to create a link
ln -s /usr/bin/node /usr/local/bin/node
Does anyone know why?
Recommend you to use nvm, very simple and can avoid many problems.
step one:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
step two:
nvm install stable
Check if successful:
node -v
I have solution for my problem. After re-login, everything is fine. I think the problem was somewhere in the ENV setup and reloaded after new login.

node -bash: /usr/sbin/node: No such file or directory

I am having this error with node. Running Debian 7 (Wheezy) a VPS.
I have this error if I for example run this command (in the directory of the .js)
node sell.js
or
screen node sell.js
They both don't work, because I am getting this error:
-bash: /usr/sbin/node: No such file or directory
Can somebody help me?
As in #Quentin's answer, the name of the executable may be incorrect. In many cases, what got installed was nodejs, not node. The line below creates a symbolic link that points to nodejs from where your system looks when you type node. It is a work-around - an alternative to simply typing nodejs
sudo ln -s /usr/bin/nodejs /usr/sbin/node
The Debian package for NodeJS is called nodejs and installed the executable /usr/bin/nodejs.
node is the wrong program, it is for ham radio operations, and your install of it appears to be broken anyway).
I ran the command:
sudo apt-get install nodejs-legacy
and nodejs worked again!
Maybe something wrong happened during your node's installing.
And system environment variable shows the command "node" referes to /usr/sbin/node .
Try download node linux binaries from official. Rename and put it in /usr/sbin after extracting the source. Of course you can put it in another folder as long as you update the system environment variables.

nodejs is already the newest version but "node -v" doesn't give a response

This is really confusing me. If I type "node -v" into the command line, there is no response - it just gives me the $ prompt again. Trying to install node with sudo npm install nodejs gives the response nodejs is already the newest version.
How can I debug this to find out what's going on?
nodejs -v solved the problem.
In some linux distributions node executable is mapped into nodejs.
Are you trying to print the node version? If yes then try
$ node --version
Node is by default installed on /usr/bin/ directory on linux OS it means it should run with normal user privilege but node include some tools that required Superuser privilege so ...
Instead running
node -v
run
sudo node -v
hope it will work...keep coding

node.js on Raspberryp]Pi not showing any terminal output

I've installed node.js on my RaspberryPi running Raspbian using
sudo apt-get install nodejs npm
it looks as though it has installed, I got no errors on installation, but when I check the version, I don't get any terminal output from node -v or node --version.
I wrote a simple js file just outputting test to the console, and when I run that from the command line with node index.js, I also don't get any output in the command line.
Is there something I'm doing wrong here? is the Raspbian terminal in some way different from other platforms (I can't imagine it is).
I've also installed following the directions in this post (up to configuring the server) http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/ and get the same result, no output in the console
The debian packages for node.js usually don't provide the binary as node (/usr/bin/node) but rather as nodejs (/usr/bin/nodejs) due to possible naming conflict with another binary from another package. (See also http://ypcs.fi/howto/2013/03/23/nodejs-debian/ for example) So you should call nodejs -v etc.
Alternatively/additionally, you can create a symbolic link with ln -s /usr/bin/nodejs /usr/bin/node. Useful expecially if you have to run shell script that expect node to be named node.
I ended up having to re-create my raspbian image (not sure why), and after trying countless different ways of installing node, I ended up using this script https://github.com/midnightcodr/rpi_node_install, it took forever, but it worked in the end.
I've also more recently seen posts which say sudo apt-get install node-js, but didn't try that one myself.

Resources