Updating npm packages

Node.js

10/31/2019


Check the version of packages

BASH
$ npm list react react-dom react-scripts

Update

Inside package.json

JSON
{
"dependencies": {
"gh-pages": "2.0.1",
"react": "^16.8.6",
"react-dom": "^16.8.6"
}
// ...
}

Adding a ^ sign in front of version allows npm to update to latest stable version. When trying to npm install without ^ sign, it will install the exact version.

BASH
$ npm update
  • Update packages to latest version, even without ^ sign.

  • Sometimes update might fail because of versions noted in lock file.

  • There may be vulnerabilities regarding security issues in the message.

BASH
npm audit fix

Updates to version that doesn't have security concerns.


WRITTEN BY

Keeping a record