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.
$ sudo apt update -y && sudo apt upgrade -y
Wait a very long time...
(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.
$ nvm --version
Should return the version of nvm installed. (for me 0.25.4)
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