NPM (Node Package Manager)
npm
is the package manager for the Node JavaScript platform. Over time packages used in an application will become outdates and should be updated to newer versions.
Updating Node packages
Tested On
- Firebase Cloud Fucntions
- Angular Project
References
Steps
-
Navigate to the folder with the
package.json
file and thenode_modules
directory.Note: If there is a new minor or patch release and we type
npm update
, the installed version is updated, and the package-lock.json file diligently filled with the new version. - To view outdated packages:
$ npm outdated
Demo:
- To update to a new major version all the packages, install the npm-check-updates package globally:
$ npm install -g npm-check-updates
Demo:
then run the updates:
$ ncu -u
this will upgrade all the version hints in the package.json file, to dependencies and devDependencies, so npm can install the new major version.
Demo:
-
Installing the updates.
If you just downloaded the project without the node_modules dependencies and you want to install the shiny new versions first, just run
npm install
If you already had a node modules folder and just want to update it, then run:
$ npm update
Demo:
Note: Running
npm update
in the demo is blank because nothing needed to be updated since we just ran npm install. - Test if your project runs. If your project does not run, try deleting the
node_modeules
directory and thepackage.lock
then recreating them with the following command (run the command in the directory where thepackage.json
is located.)$ npm install
Demo:
Note: If you have an error with a specific package, it may help to remove the package from node modules with npm uninstall <package name>
then running npm install
again.
Journal
- 2020.06.21 Created how to update node
- 2020.06.26 Updated file name to
NPM
and updated description