Sunday, May 12, 2019

Self upgrade of npm and node.js

Even I'm an old Java developer, I'm a newbie on node and npm and it's a new playground for me.

My project is to product some JS code (maybe TypeScript). As every software architect, my first question was : how to structure, package and deliver my project. This is done with npm (the package manager from node.js).

I've got npm on my laptop (installed with a classic sudo apt-get install npm) but I realized it's an old release.

Hopefully, node.js echosystem is great and everything can be self upgraded. Thus, you don't need any new debian package.  Great! Let's'do this :

# Let's upgrade node.js to the last stable release 
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

# Then, we upgrade npm
sudo npm install npm@latest -g

# If your npm -v doesn't return the new version, you sould have multiple npm executable in your path
# On my Ubuntu, I changed the symbolic link
sudo ln -sf /usr/local/bin/npm /usr/bin/npm

That's all!

No comments:

Display Javascript console logs with jsfiddle

Jsfiddle is mainly made to test javascript code in a web context (aka with HTML and CSS). But, if you just want to use is to test backend c...