mandag 15. juni 2015

How to update node.js (at least on on a MacBook pro)

For some time ago I installed node.js on my MacBook Pro. Beeing a side-project I did not have enough time to play much with it...

Tonight I however found that it was time to take a look at the Polymer Starter Kit. The kit is enabled for use with Yeoman. Since Yeoman proudly states that they are "THE WEB'S SCAFFOLDING TOOL FOR MODERN WEBAPPS" it seemed like a good starting point.

Yeoman had to be installed, and Node Package Manager was the tool for the job. I quickly realized that I had to update npm:

$ sudo npm install -g npm
Then it was time to install Yeoman:

$ sudo npm install -g yo
Error messages (!?!?!?) rolled over my console...
After googling the error I found that my node.js install was way to old. Since I am using a regular .dmg install I could of course just download a newer installable from the node.js home page.

At the time however the following command seemed like a much nicer way to go:

$ sudo npm cache clean -f
npm WARN using --force I sure hope you know what you are doing.
$ sudo npm install -g n  
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n 
n@1.3.0 /usr/local/lib/node_modules/n
$ sudo n stable

After  installing node -v revealed that my node.js installation was updated to versjon 0.12.4.

Nice!!