Node.js installation with nvm on Raspberry pi

Hadi Azami edited this page Aug 18, 2018 · 4 revisions

Requirements:

  • A Raspberry pi with Raspbian installed.
  • An internet access.

Update Raspbian

$ sudo apt update -y && sudo apt upgrade -y

Wait a very long time...

Install nvm

(Node Version Manager, https://github.com/creationix/nvm)

Execute following commands:

$ git clone https://github.com/creationix/nvm.git ~/.nvm
$ sudo echo "source ~/.nvm/nvm.sh" >> ~/.bashrc && sudo echo "source ~/.nvm/nvm.sh" >> ~/.profile

Exit all terminals and/or ssh sessions and open a new one.

Check if installation work

$ nvm --version
Should return the version of nvm installed. (for me 0.25.4)

Install Node.js

You can see all available version of node js at this url http://nodejs.org/dist/. When you click on http://nodejs.org/dist/v0.10.26/, you can see that it was compiled for the raspberry pi (you can see the file: node-v0.10.26-linux-arm-pi.tar.gz).

Install node.js and upgrade npm by running these commands:

$ nvm install 8.11.4 

# Or this (for latest LTS version)
$ nvm install --lts

# Switch to installed node version
$ nvm use 8.11.4 

# Or switch to LTS
$ nvm use --lts

# then update npm
$ npm -g install npm@latest --allow-root --unsafe-perm 
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.