I am by no means a virtuoso when it comes to Node, Grunt, etc., so when I ran into a Grunt plugin breaking (grunt-icon, to be exact: “grunticon now spawning phantomjs”), the only search result I could find was this issue which appears to be solved, but via grunt-icon update. So, I set about updating my grunt-icon installation.
So, how do you do that… :-/
Naturally, I Googled “windows update grunt-icon” and got a never-ending stream of results that all talked about installing grunt-icon… Thanks to a co-worker that knows Node pretty well, and a couple trips and stumbles after that, I found the solution.
Cutting to the chase, to update Node, Grunt, and all my Grunt plugins, this is what I did:
- Download the latest version of Node
- Install that Node version
- Manually hunt for the latest version numbers for Grunt and each Grunt plugin that you use (Google helps, of course, but then, if you can find the Github page, try checking for a Release Notes section, like this one for contrib-less)
- In your package.json file and you should see something like this:
"dependencies": { "grunt": "0.4.5", "grunt-contrib-less": "0.11.1", "grunt-contrib-watch": "0.6.1", "grunt-contrib-uglify": "0.4.0", "grunt-grunticon": "1.2.0" }
- Update each of those numbers to the latest versions you found
- Save the file
- From the command line, run
npm install
- If all goes as planned, Node, which you already updated, should run through everything in your package.json file and check if you have that version installed; if not, download and install it.
This fixed my PhantomJS issue, though create another issue because Grunt changed its syntax, so I had to re-write some of the package.json references, but after, I had everything working again!
Is there no better way to do this? What I was hoping to find was something like:
node update -all
That would simply update Node, then Grunt, then all the plug-ins, to their latest stable versions.
Would love to hear about a better method.
Happy grunting,
Atg
I have a simple alias in my .bashrc to run a npm check update and the install updated version
alias npmui=''npm-check-updates -u && sudo npm install'
You don’t have to hardcode version numbers exactly like that. You can use e.g. 0.4.x or ~0.4.5 (any 0.4) or ^0.4.5 (any 0.4 or higher) or even * (any latest) and then just npm update.
Also npm outdated –depth=0 is very nice :)
Thanks to both gwen & Dominykas! Both of these options seem MUCH easier than my method described above… :-)