Skip to content

Instantly share code, notes, and snippets.

@hanigamal
Forked from myrtleTree33/install-node-pi.sh
Created June 29, 2017 03:52
Show Gist options
  • Save hanigamal/9ddd7e080d2e7f660efe17035c294038 to your computer and use it in GitHub Desktop.
Save hanigamal/9ddd7e080d2e7f660efe17035c294038 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment