Raspberry Pi

How to Install NVM and Node.js on Raspberry Pi

Node Version Manager, commonly referred to as NVM, is a tool for installing and using different versions of Node.js on your system. This tool is helpful for users whose programs require different versions of Node.js and installing them from scratch is a hectic task. Thus, the developers introduce a way to easily install any Node.js version and switch to the desired version within seconds.

This guide will help you in installing NVM on Raspberry Pi and later, it also shows you the way to use it for installing different versions of Node.js.

Install NVM and Node.js on Raspberry Pi

The installation of NVM on your Raspberry Pi system is quiet simple, which requires executing the following script on your Raspberry Pi terminal.

$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

After the installation, close the terminal and open it again to confirm the installation of NVM on your Raspberry Pi system from the following command:

$ nvm -v

Install Node.js Versions Through NVM

Now to start installing the latest stable version of Node.js on your Raspberry Pi system, follow the below-mentioned command:

$ nvm install stable

You can check the Node.js version using the command mentioned below:

$ node -v

If you want to install an old version of Node.js, you can use the following syntax:

$ nvm install <node.js-version>

To install version 8, use the command:

$ nvm install 8.0.0

You can also install the latest LTS version of Node.js through the following command:

$ nvm install --lts

To switch to any Node.js version, you can use the following command with the version you want to use.

$ nvm use <Node.js version>

 

To switch to the version 8.0.0, use:

$ nvm use 8.0.0

To switch to the latest Node.js version, you can use the following command:

$ nvm use node

Conclusion

NVM is a tool for installing and using different versions of Node.js on your Raspberry Pi system. It can be installed directly from the script, which needs to be executed in the Raspberry Pi terminal. After the installation, you can easily install different versions of Node.js through the “nvm install” command and use the particular Node.js version on your Raspberry Pi system through the “nvm use” command.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.