Installing node LTS version on Ubuntu 14.04

In a previous post, Installing Node.js and npm on Ubuntu 14.04, I installed nodejs on Ubuntu 14.04 using what were current instructions at the time. Those notes are outdated at this point so I thought I’d document the current way to install the LTS version of node.

To install we will be following the (very brief) guide at debian node install – this uses a simple curl/bash combination to setup a PPA for the LTS version of node (currently ver 4.4.0). Installation is as simple as:

$ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
$ sudo apt-get install -y nodejs

This sets you up for automatic updates of the version 4.2+ LTS version of node– an active LTS through April 2017, according to the node LTS schedule. Once the install is complete, you can find out versions of node and npm using:

$ node --version
v4.4.0
$ npm --version
2.14.20

Of course, your versions might be different if you install later.

sudo-free global installs

2016, July

I’m adding this (I think) really important part to allow for npm install of packages without sudo – this means it’s in a non-destructive place that we have to setup. This approach is suggested by the (very nice) npm docs– see here – I’ll be using “Option 2” described there. To start, we make a directory to hold our global installs:

$ mkdir ~/.npm-global

Next, we tell npm about this new location:

$ npm config set prefix '~/.npm-global'

Finally, we have to update our path for bash. The npm docs suggest doing this in ~/.profile, but I will do this in ~/.bashrc (this is loaded by ~/.profile on Ubuntu machines). So, in ~/.bashrc add this line (at the end of the file is fine)

# add path for npm global installs
export PATH=~/.npm-global/bin:$PATH

I’ve added the comment so that I/we can remember what this is for (if it isn’t obvious from the name). Finally, source ~/.bashrc like so

$ source ~/.bashrc

And we should be set; global install without sudo. If you’d like to test it out, install jshint globally with:

$ npm install -g jshint

You should see that it is using the new location.

Geting started

If you are new to nodejs – I’m still pretty new – you should look into

  • nodeschool is a place to learn about node, with local meetings that you can attend if you are lucky. I’ve been to the Oakland nodeschool and found it really useful.
  • Self-directed node lessons are available in the node workshopper list, starting with basic javascript and moving on to more advanced topics ranging from Reactjs to the Web Audio API. These are installed using npm and pretty easy to use. Also, these lessons form the basis for the nodeschool meetings, providing the basis for learning all things javascript and node.

That’s it for this short post. Please leave comments if you have issues or other ideas on how to get started learning nodejs– I’d love to see them!

Tags

api [1]   arduino [1]   audio [2]   audio features [1]   babel [1]   Bayesian [7]   Beta [1]   blog setup [1]   bootstrap [1]   bottleneck [1]   c++ [1]   caret [1]   cmpy [1]   conditional probability [6]   coursera [1]   coursera intro to data science [3]   css [1]   cython [1]   d3 [2]   decision trees [2]   diy [1]   dropbox [1]   dsp [1]   e1071 [1]   essentia [1]   garmin [1]   geojson [1]   ggplot2 [1]   gis [2]   git [1]   gnuplot [1]   graphs [1]   html5 [1]   igraph [1]   ipython [1]   javascript [7]   joint probability [6]   json [1]   LaTeX [2]   LDA [1]   Lea [2]   machine learning [3]   marginal probability [6]   matplotlib [1]   meteor [2]   mir [1]   MongoDB [3]   music [2]   my python setup [5]   my ubuntu setup [10]   mysql [3]   networks [1]   networkx [1]   nodejs [5]   npm [3]   numexpr [1]   numpy [1]   octave [1]   Open Oakland [2]   openpyxl [1]   pandas [3]   patsy [1]   pip [2]   pweave [1]   pygraphviz [1]   pymc [1]   PySoundFile [2]   python [15]   Python [1]   python 2.7 [5]   python 3.4 [2]   pyyaml [1]   qgis [1]   R [1]   randomForest [1]   restview [1]   resume [1]   rpart [1]   running [1]   scikit-learn [3]   scipy [1]   screen [1]   server setup [1]   shapefile [1]   social networks [1]   Socrata [1]   sound [2]   sphinx [1]   sql [4]   sqlite3 [1]   ssh [1]   ssh keys [1]   statsmodels [1]   supervised learning [2]   sympy [1]   tableau [1]   tinkerer [2]   topic models [1]   tree [1]   ubuntu 14.04 [13]   Ubuntu 14.04 [3]   ubuntu 16.04 [4]   vim [2]   virtualbox [1]   virtualenv [4]   virtualenvwrapper [3]   VPS [1]   vundle [1]   webpack [1]   yaml [1]