Thursday, February 1, 2024

How to Install COMPLETE NodeJS Stack on Raspberry Pi 3, 4, and 5

 


Node.js, built on the V8 JavaScript engine, brings the versatility of JavaScript to the server-side, enabling developers to use the same language for both client and server applications. Known for its non-blocking, event-driven architecture, Node.js is a go-to choice for building scalable and high-performance applications. Its lightweight nature makes it a perfect fit for resource-constrained environments, such as the Raspberry Pi.

Run all of these command, step by step:

# remove node if it exists
sudo apt-get remove nodejs npm node
sudo apt-get purge nodejs
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/share/man/man1/node*
sudo rm -rf /usr/local/lib/dtrace/node.d
rm -rf ~/.npm
rm -rf ~/.node-gyp
sudo rm -rf /opt/local/bin/node
sudo rm -rf /opt/local/include/node
sudo rm -rf /opt/local/lib/node_modules
sudo rm -rf /usr/local/lib/node*
sudo rm -rf /usr/local/include/node*
sudo rm -rf /usr/local/bin/node*
sudo apt autoremove
sudo apt autoclean
# install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
sudo su
# (this wil result in installing v15.5.1)
nvm install node 
nvm use node
# install latest node with long term support
nvm install --lts
nvm use --lts
npm config set scripts-prepend-node-path auto

You're welcome

0 comments:

Post a Comment