How can you quickly check if you package.json file has modules that could be updated to newer versions?

How can you quickly check if you package.json file has modules that could be updated to newer versions?

For example, a quick way to check if either express or nodemailer has an available update?

{
    "name": "some_module_name"
  , "description": ""
  , "version": "0.0.3"
  , "dependencies":  {
           "express": "3.1"
         , "nodemailer" : "0.4.0"
    }
}

I read over the FAQs, but didn't see anything: https://npmjs.org/doc/faq.html

Thanks.

Yes there is an option :

npm outdated

This will list modules, with available updates. It supports syntax for specifying the module name.

According to the Documentation, the syntax is

npm outdated [<name> [<name> ...]]

This gives you to specify the module name you wish to check exclusively, like

$ npm outdated mongoose

Note

To use this properly, you'll have to add a version number of the target module(s) with range greater than or greater than or equal. You can check node-semver, which is integrated into npm to check the syntax.

Example

{
    "dependencies": {
        "express": "3.2.0",
        "mongoose": ">= 3.5.6",
    },
}

Will give the following result ( since today the latest mongoose version is 3.6.9 )

$ npm outdated
...
mongoose@3.6.9 node_modules/mongoose current=3.6.7
$

While if you place

{
    "dependencies": {
        "express": ">= 3.2.0",
        "mongoose": ">= 3.5.6",
    },
}

The result will be :

$ npm outdated
...
mongoose@3.6.9 node_modules/mongoose current=3.6.7
express@3.2.3 node_modules/express current=3.2.0
$

there's a service like travis that checks it automatically:

https://gemnasium.com

you need to do that manually using the update command:

$ npm update

you can also change the version:

"nodemailer": "*" // this would use the newest version

or

"nodemailer": ">=0.4.0" // this will install any version which is at least 0.4.0

and so on....

read more about that here: https://npmjs.org/doc/json.html#dependencies

EDIT: there is some possibility if the module is available via github. you can then "watch" that repo, and get notification updates!

You might want to check out https://david-dm.org/ as it is free service that does the check. This is more target at adding a build badge to your README, but the details it gives on the page are quite helpful.

See https://david-dm.org/jshint/jshint as an example output.