Skip to content

Instantly share code, notes, and snippets.

@davidlares
Last active April 17, 2019 04:45
Show Gist options
  • Save davidlares/77819bb989d865d5cc778f444f20288f to your computer and use it in GitHub Desktop.
Save davidlares/77819bb989d865d5cc778f444f20288f to your computer and use it in GitHub Desktop.
Node's NPM CLI commands and SemVer for software projects

NPM Commands

  1. npm init: NPM package manifest wizard
  2. npm whoami: check for the authenticated user
  3. npm adduser: add a user to the NPM session
  4. npm init --scope=<username>: add the auth user to the NPM .json manifest
  5. npm install <modulename>: installing a specific NPM module or package
  6. npm ls: dependencies listing (specific directory)
  7. npm test: run tests using the scripts located at the package.json file
  8. npm publish: publish a package to the NPM repository, or updates or bug fixes
  9. npm view @davidlares/how-to-npm-davidlares: check package details
  10. npm version: modify the package.json in order to the specified version

SemVer (Semantic Versioning)

Patch Version -> Update every change (third number)

Minor Version -> Update for API additions (second number)

Major Version -> Update for breaking API changes (first number)

Tags

Tags usage: by default = latest

Add tag

You can add tags to the previous versions of the code, but no the last of it By default: the last one automatically have the 'latest' tag

npm dist-tag add [email protected] beta

npm dist-tag add @davidlares/[email protected] beta

Remove tag

You will unable to delete LATEST tag npm dist-tag rm @davidlares/how-to-npm-davidlares <tag>

Other commands

  1. npm outdated: check for outdated packages
  2. npm update: update project dependencies
  3. npm rm <PKG>: remove project dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment