Skip to content

Latest commit

 

History

History
163 lines (126 loc) · 2.87 KB

nvm-npm.md

File metadata and controls

163 lines (126 loc) · 2.87 KB

NPM + NVM

NVM (Node Version Manager for using multiple node version in same machine)

  • Download from here

  • To see version of nvm.

    nvm version

    or

    nvm v
  • Show if node is running in 32 or 64 bit mode. Specify 32 or 64 to override the default architecture.

    nvm arch [32|64]
  • To see all the node versions available for installation.

    nvm list available
  • To install the latest version of node.

    nvm install latest
  • To install the LTS version of node.

    nvm install lts
  • Install a specific version of node.

    nvm install <version>

    example

    nvm install 18.3.0
  • Uninstall a specific version.

    nvm uninstall <version>

    example

    nvm uninstall 18.3.0
  • See all the installed node version.

    nvm ls
  • To specify or change the current active version.

    nvm use <version>

    example

    nvm use 18.3.0
  • To see active version name/no.

    nvm current

8 Useful Npm Commands

1. Open a package’s documentation page

npm docs [package-name] // npm docs lodash

2. Open a package’s GitHub repo

npm repo [package-name] // npm repo lodash

3. Check packages for outdated dependencies

npm outdated // run it in a project

4. View all historical versions of a package

npm v [package-name] versions // npm v lodash versions

5. Find risky packages in your project

npm audit // run it in a project

6. View details of a package

npm v [package-name] // npm v lodash

7. npm xmas (For Fun)

npm xmas

8. npm visnup (For Fun)

npm visnup

Npm Commands For Global Execution

  1. Get list of all globally installed npm packages

    npm list -g
  2. Check if the package is globally installed

    npm list -g <package-name>
  3. Uninstall global package

    npm uninstall -g <package-name>
  4. Check which packages are outdated

    npm outdated -g
  5. Update all global packages

    npm update -g
  6. Update a global package

    npm update -g <package_name>

Npm Commands For updating dependency versions

  1. Check all the upgradable dependency lists

    npx npm-check-updates
  2. Update all dependency version in package.json file

    npx npm-check-updates -u