Quick Tip: Updating your node modules is easy as »1, 2, 3«
»npm«
Quick Tip, npm, Node.js, update
It might be a »no-brainer« in case you are working within the Node.js environment for a while. But I used to ask myself how to figure out if there are updates to my dependencies / devDependencies which are beyond the patch-level updates which are »automatically« installed via the definition within my `package.json`. Because I don’t like to check possible updates separately for every module I’m using in my project.
Fortunately there is a node module which can handle that for all dependencies within your project and even all your globale modules. It’s called npm-check-updates and will also update your package.json
file if you like to. So updating becomes »fun« again
Using this is pretty straight forward. First you need to install the package globally with:
npm install -g npm-check-updates
Then use the modules cli without any option to check available updates within your projects root directory:
npm-check-updates
This will show you all possible updates without changing anything:
"superb" can be updated from ^1.0.5 to ^1.1.1 (Installed: 1.0.5, Latest: 1.1.1)
"mocha" can be updated from ^2.0.1 to ^2.1.0 (Installed: 2.0.1, Latest: 2.1.0)
"should" can be updated from ^4.4.2 to ^4.6.1 (Installed: 4.4.2, Latest: 4.6.1)
Run 'npm-check-updates -u' to upgrade your package.json automatically
If you like to upgrade your projects package.json
file just make use of the -u
option as mentioned in the output above and fire:
npm install
afterwards. And … all updates will land on your machine and you’re done.
See the README for more options.
Related posts
- How to flash ESP8266 (and ESP32) to use Espruino firmware on macOS
- Helpers and tips for npm run scripts
- JSConf Budapest 2017 – A personal recap
Comments
Comments are removed for now. Feel free to contact me via Twitter in case you’d like to talk about this blog post: @mkuehnel.