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.
To update a specific package, we need to run the npm update command followed by the package name. Sometimes, you want to update a package to the specific version in such cases you need to use npm install command by specifying a version number after the package name.
Updating packages to the most recent major version json to the latest major version if they are sure that the project will still work without breaking anything. Doing so will update the version numbers specified in the front of each package, hence updating the project's package. json file.
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
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.
{
"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
...
[email protected] 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
...
[email protected] node_modules/mongoose current=3.6.7
[email protected] 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With