nodejs is already the newest version but “node -v”

2020-05-03 11:46发布

问题:

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?

回答1:

nodejs -v solved the problem.

In some linux distributions node executable is mapped into nodejs.



回答2:

Are you trying to print the node version? If yes then try

$ node --version



回答3:

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