How to install Node.js and npm on Raspberry Pi

Enable the NodeSource repository by running the following command in your terminal:

curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -

Copy

The current LTS version of Node.js is version 10.x, Dubnium. If you want to install Node.js version 8.x just change setup_10.x with setup_8.x

Once the repository is enabled, install Node.js and npm by typing:

sudo apt install nodejs

To verify the installation, run the following command which will print the Node.js version:

node --version
v10.16.