#Installing NPM and Node on Ubuntu 13.04 without sudo
###Make Directories $ mkdir ~/Downloads $ mkdir -p ~/local/node
###Change to Downloads directory $ cd ~/Downloads
###Download latest node package and unpack it $ wget http://nodejs.org/dist/node-latest.tar.gz $ tar xzf node-latest.tar.gz -C ~/local/node --strip-components=1
###Add to path $ echo '# Node Enviroment Setup' >> ~/.bashrc $ echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.bashrc $ echo 'export NODE_PATH=$HOME/local/node/lib/node_modules' >> ~/.bashrc
###Reload .bashrc -- Don't forget the first . $ . ~/.bashrc
###Check Node & NPM versions $ node -v $ npm -v
#Creating update script
###Create server script directory
This is where I generally keep scripts to do everyday tasks
$ mkdir ~/server-scripts
###Change to server-scripts directory $ cd ~/server-scripts
###Create update-node.sh bash script $ nano update-node.sh
###update-node.sh contents
This is the contents of update-node.sh -- you can just paste it in
#!/bin/bash
#change directories
echo 'Changing Dirs'
cd ~/Downloads
#download latest node and unpack
echo 'Downloading latest Node...'
wget http://nodejs.org/dist/node-latest.tar.gz
echo 'Unpacking and installing...'
tar xzf node-latest.tar.gz -C ~/local/node --strip-components=1
#remove the downloaded package
echo 'removing package...'
rm node-latest.tar.gz
#remind me to reload .bashrc
echo 'Done!'
echo '-- Please run `. ~/.bashrc`'
###Make it executable $ chmod +x update-node.sh
###Make a symbolic link $ cd /usr/bin $ sudo ln -s ~/server-scripts/update-node.sh update-node $ [enter sudo password]
###Check to see if everything works out!
First, I'm going to my home directory, because I like to be there
$ cd
$ update-node
##Hopefully you should see the bash script run and then you can check your node version to see if it went alright
$ node -v