get npm package version code example

Example 1: npm check package version

local packages:
~$ npm list

globally installed packages:
~$ npm list -g

specific package:
~$ npm list <package>

Example 2: npm get latest version of package

npm show {pkg} version

Example 3: find npm version

npm --version

Example 4: npm get version

npm view <package> version

Example 5: how to install latest version of npm package

//For global packages 
npm i -g <package name>@latest
npm i -g express@latest

//For loacal packages
npm outdated
npm update

//Manually updating local packages
npm i <package name>@latest
npm update "react" "react-dom"

Example 6: npm package version

// How to increment your project version
Ex: 1.0.0

* npm version patch ---> 1.0.1
* npm version minor ---> 1.1.0
* npm version major ---> 2.0.0

npm version [<newversion> | major | minor | patch | premajor | 
preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]