Sunday, October 11, 2015

Hey, learned something new - quick way to update nodejs modules!





I've got a lot of modules installed for most of my app - node is awesome just considering the versioning and install process.  It's really easy to make some powerful components by chaining together others - and you can lock your app to use certain versions and the installer just does the right thing with them.  It almost always makes a working installation with two commands - which is a miracle if you ever tried to deploy any large custom application.

There's no functionality to migrate out of the older code into the new though - but there usually isn't such a thing anyway.  But I got stuck since there were security updates to some low level components that resulted in the older version being taken down - so I couldn't install a new system.  Then I found npm-check-updates.

This app 'fixes' the dependency tree by walking all the possible combinations and updating everything as far as it can be done.  This would have taken me hours - this is really an awesome app.


root@hackathon:~# npm install -g npm-check-updates
/usr/local/bin/npm-check-updates -> /usr/local/lib/node_modules/npm-check-updates/bin/old-alias
...
bower-config@0.6.1, inquirer@0.8.0)
└── npm@3.3.6


Annoyingly - the app is called ncu instead of npm-check-updates.  Like we don't have enough damned applications called ncu.

Invoke with -u to update the npm json file.

root@hackathon:~/the-app/server# ncu -u

 bitcoinjs-lib                   ~1.5.6  →    ~2.1.1
 body-parser                     ~1.5.0  →   ~1.14.1
...
 grunt-contrib-clean             ~0.5.0  →    ~0.6.0

And then update bower (you need to run bower update once at least to regenerate the files):

root@hackathon:~/the-app$ ncu -m bower -u

 angular-bootstrap  ~0.11.0  →  ~0.14.0
 angular-socket-io   ~0.6.0  →   ~0.7.0
 lodash              ~2.4.1  →  ~3.10.1
 request            ~2.64.1  →  ~2.65.1

Upgraded /home/awoah/awoah-web/bower.json

And you can check in the module list.  All updated in a few steps - which is awesome.  :)




No comments:

Post a Comment