Skip to content

Instantly share code, notes, and snippets.

@HendrikRoth
Forked from myrtleTree33/install-node-pi.sh
Last active January 31, 2018 11:45
Show Gist options
  • Save HendrikRoth/823c0eff61f3f5b236c61e86a9621829 to your computer and use it in GitHub Desktop.
Save HendrikRoth/823c0eff61f3f5b236c61e86a9621829 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="v8.2.1"
##########################################################################
#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_VERSION}-linux-armv6l.tar.gz
#unpack
tar xvzf node-${NODE_VERSION}-linux-armv6l.tar.gz
#Copy to the dir you made as the first step
sudo cp -r node-${NODE_VERSION}-linux-armv6l/* /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="v8.2.1"
##########################################################################
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-armv6l.tar.gz
#unpack
tar xvzf node-${NODE_VERSION}-linux-armv6l.tar.gz
#Copy to the dir you made as the first step
cp -r node-${NODE_VERSION}-linux-armv6l/* /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