Node.js is a powerful JavaScript runtime. Node lets developers run Javascript outside of browsers. It is handy to be able to work with just about any Raspberry Pi project. Hopefully, you’ll only need one search next time! (and hopefully, I’ll remember that I wrote this, so I won’t need any!)
Install a few handy packages using apt you might not need these, but I find them necessary for many of my projects.
sudo apt update
sudo apt install build-essential git
Remove any outdated copies of Node.js – you might have a node installation on your Pi already. Still, chances are it’s not the one you want.
sudo apt install node- npm-
- apt will uninstall a package when you follow its name with a -
sudo apt autoremove
#this will clean out unused packages
Once things are cleaned up, install the Node Version Manager, NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
Make sure to exit and relaunch your terminal.
Install the latest NodeLTSRelease
nvm install --lts
nvm use --lts
Install the Yarn dependency manager, which we’ll use to run our app:
npm install --global yarn
That’s it – easy, when you have everything in place! With Node and Yarn fully setup, you can get started with doing local Dev and Quality assurance of projects that are powered by Node.