npm install version of package code example
Example 1: install npm globally
npm install npm@latest -g
Example 2: how to install specific package version npm
$ npm install express@4.16.1
+ express@4.16.1
added 48 packages from 36 contributors and audited 121 packages in 2.986s
found 0 vulnerabilities
Example 3: how to install latest version of npm package
npm i -g <package name>@latest
npm i -g express@latest
npm outdated
npm update
npm i <package name>@latest
npm update "react" "react-dom"
Example 4: install node modules
npm install --save packageName
npm install --save package1 package2
npm install --save package@version
npm i -s packageName
npm install --save-dev package@version
npm i -D packageName
npm install --global packageName
npm i -g packageName
Example 5: npm package 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]
Example 6: npm package at version
npm install <package>@<version>