The npm application is a package manager that’s bundled with the Node.js server.
When you install Node.js, you will get a certain version of npm installed on your computer.
Because Node.js release new versions at a slower pace than npm, the included npm version can be outdated after a while.
When you want to update the npm package, run the command
npm install -g npm@latest.
Here’s an example of updating npm from version 6 to version 8:
$ npm -v 6.14.17 $ npm install -g npm@latest + firstname.lastname@example.org $ npm -v 8.12.1
As of this writing, the latest version of npm is version 8, so it was installed.
The latest stable version should be installed when you run the command in the future.
And that’s how you update the npm application included with your Node.js server.