From article These NPM tricks will make you a pro on FreeCodeCamp.

List

$ npm list

Flags

  • --depth=0 - Top-level packages.
  • -g - Global packages.

Remove duplicates

$ npm dedupe

Outdated

$ npm outdated

Update

Update packages to the latest versions. This will stay within the bounds set by package.json such as ~ or ^.

$ npm update

If you want to force everything to the most modern version, ignoring the versions set in package.json, run this:

$ npx npm-update-all

That downloads and runs the npm-update-all package.

Open pages

Open the repository, homepage or docs page in your browser.

$ npm repo PACKAGE
$ npm home PACKAGE
$ npm docs PACKAGE

Clean scripts

{
  "scripts": {
    "test": "jest",
    "format": "eslint src --fix"
  }
}

Customize IDE

Add this to VS Code settings

npm.enableScriptExplorer: true

Set defaults

Tired of setting up using npm init or npm init -y commands?

Then change defaults.

$ npm config set init.author.name "Carl-Johan (C-J) Kihl"
$ npm config set init.author.email "carljohan.kihl@mail.com"