Skip to content

Instantly share code, notes, and snippets.

@myrtleTree33
Last active March 8, 2024 22:37
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save myrtleTree33/8080843 to your computer and use it in GitHub Desktop.
Save myrtleTree33/8080843 to your computer and use it in GitHub Desktop.
Install Node JS in 30 seconds for Raspberry Pi / ARM
#!/bin/bash
## Check for versions compiled with ARM at http://nodejs.org/dist/
## Inspired by http://oskarhane.com/raspberry-pi-install-node-js-and-npm/
## Fill in the Node Version here:
##########################################################################
NODE_VERSION="v0.10.21"
##########################################################################
#Make a new dir where you'll put the binary
sudo mkdir /opt/node
#Get it
wget http://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERRSION}-linux-arm-pi.tar.gz
#unpack
tar xvzf node-${NODE_VERSION}-linux-arm-pi.tar.gz
#Copy to the dir you made as the first step
sudo cp -r node-${NODE_VERSION}-linux-arm-pi/* /opt/node
#Add node to your path so you can call it with just "node"
#Add these lines to the file you opened
PROFILE_TEXT="
PATH=\$PATH:/opt/node/bin
export PATH
"
echo "$PROFILE_TEXT" >> ~/.bash_profile
source ~/.bash_profile
# linking for sudo node (TO FIX THIS - NODE DOES NOT NEED SUDO!!)
sudo ln -s /opt/node/bin/node /usr/bin/node
sudo ln -s /opt/node/lib/node /usr/lib/node
sudo ln -s /opt/node/bin/npm /usr/bin/npm
sudo ln -s /opt/node/bin/node-waf /usr/bin/node-waf
#Test
node -v
npm -v
#!/bin/bash
## Check for versions compiled with ARM at http://nodejs.org/dist/
## Inspired by http://oskarhane.com/raspberry-pi-install-node-js-and-npm/
## Fill in the Node Version here:
##########################################################################
NODE_VERSION="v0.10.28"
##########################################################################
echo 'export PATH=$HOME/opt/node/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
#Make a new dir where you'll put the binary
mkdir -p ~/opt/node
#Get it
wget http://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-arm-pi.tar.gz
#unpack
tar xvzf node-${NODE_VERSION}-linux-arm-pi.tar.gz
#Copy to the dir you made as the first step
cp -r node-${NODE_VERSION}-linux-arm-pi/* ~/opt/node
#Add node to your path so you can call it with just "node"
#Add these lines to the file you opened
AUTO_SOURCE_BASHRC_TEXT="
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
"
echo "$AUTO_SOURCE_BASHRC_TEXT" >> ~/.bash_profile
#Get correct PATH
source ~/.bashrc
#Test
node -v
npm -v
@jeffehobbs
Copy link

Nothing about this script works anymore.

@dydFreeman
Copy link

Just tested it on a RaspberryPi with ARM6.
Worked like a charm!

@flkas
Copy link

flkas commented Jan 24, 2019

Hey @myrtleTree33 ,
in the first script could you correct following things please?

NODE_VERSION="v0.10.28" and there is a mistake in the link - this is why it doesn't work - the correct one is:
wget https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-arm-pi.tar.gz

  1. Changed node version to v0.10.28
  2. Changed http to https
  3. second ${NODE_VERSION} had a typo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment