41

I am using Ubuntu Linux.

How can I check current nodejs version? I guess, I have 6 version, but I am not sure.

And is there way to change it, because I need 4 version. Can some one give step by step commands?

halfer
  • 19,471
  • 17
  • 87
  • 173
Headmaster
  • 1,808
  • 3
  • 23
  • 45
  • Possible duplicate of [Node.js version on the command line? (not the REPL)](https://stackoverflow.com/questions/14888471/node-js-version-on-the-command-line-not-the-repl) – alexmac Aug 11 '17 at 10:07
  • You can use NVM (Node version management) to manage multiple active node.js versions. https://github.com/creationix/nvm – Andan H M Aug 11 '17 at 10:11

4 Answers4

61

Open up the terminal and type node -v

To change your node version, I'd recommend installing nvm. Once installed, to switch versions it's as simple as

nvm use <version>
James
  • 77,877
  • 18
  • 158
  • 228
23

You can check your current NodeJS version by using command node -v. And changing your version can be done by using node version manager. The easiest way to do that is by running this $ npm install -g n now you can change your current NodeJS version using n (version) e.g. n 4.0.0.

node -v
npm install -g n
n 4.0.0
Pavan Vora
  • 1,504
  • 11
  • 19
  • 2
    This does not change the active version. How do I change to the stable version, for instance. I tried:
    # n latest
    installing : node-v15.7.0
    mkdir : /usr/local/n/versions/node/15.7.0
    fetch : https://nodejs.org/dist/v15.7.0/node-v15.7.0-linux-x64.tar.xz
    installed : v15.7.0 to /usr/local/bin/node
    active : v10.13.0 at /opt/conda/bin/node
    # n stable
    installed : v14.15.4 to /usr/local/bin/node
    active : v10.13.0 at /opt/conda/bin/node
    – Kurt Peters Jan 28 '21 at 23:29
  • Yes, this is annoying, what I ended up doing was removing node (https://askubuntu.com/questions/786015/how-to-remove-nodejs-from-ubuntu-16-04) and then you can either symlink /usr/local/bin/[node~npm] into /usr/bin or you can add /usr/local/bin to your path. – satnhak Feb 25 '21 at 21:29
6

You can check your version by using this code (node -v) in linux terminal and If you want to upgrade it to stable version you can use following codes one by one.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Dinith
  • 619
  • 10
  • 20
2

Just type npm version in your command line and it will display all the version details about node, npm, v8 engine etc.

Himanshu
  • 5,903
  • 1
  • 14
  • 9