Skip to content

Instantly share code, notes, and snippets.

@rekomat
Last active November 2, 2021 21:47
Show Gist options
  • Save rekomat/8725c0316508972197979740844ba711 to your computer and use it in GitHub Desktop.
Save rekomat/8725c0316508972197979740844ba711 to your computer and use it in GitHub Desktop.

npm Cheatsheet

Update all packages to latest

# Install ncu globally
npm install -g npm-check-updates

# Run it to update all version hints in package.json 
# (dependencies and dev-dependencies)
$my-project ncu -u

# run the update
$my-project npm update

# Install if `/node_modules` are not present yet
$my-project npm i

Source: nodejs.dev

Publish package

$my-package npm publish

Source: npm Docs

Dist-Tags

List dist-tags

$my-package npm dist-tag ls

Publish with dist-tag

$my-package npm publish --tag <tag>

Add dist-tag to a specific version

$my-package npm dist-tag add <package-name>@<version> [<tag>]
# Example
$my-package npm dist-tag add example-package@1.4.0 stable

Remove dist-tag

$my-package npm dist-tag rm <package-name> <tag>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment