Js: Npm

Node Package Manager: commands and versioning. Links: docs for npm command

7 flashcards · Programming Languages · by lakesare

  1. What is semver?

    Semantic versioning - Links: https://docs.npmjs.com/getting-started/semantic-versioning

  2. 1.0.0 What does each digit stand for npm's semantic versioning?

    1.0.x - bug fixes 1.x - new features, not breaking backwards compatibility x - anything breaking backwards compatibility As a consumer, you can specify which kinds of updates your app can accept in the package.json file.If you were starting with a package 1.0.4, this is how you would specify the ranges:Patch releases: 1.0 or 1.0.x or ~1.0.4Minor releases: 1 or 1.x or ^1.0.4Major releases: * or x

  3. What does this mean in package.json? "moment": "^2.18.1",

    Same with 2.x, on npm install it will update all nonbreaking changes.

  4. "moment": "^2.18.1", VS "moment": "~2.18.1",

    "moment": "^2.18.1", //=> 2.x VS "moment": "~2.18.1", //=> 2.18.x

  5. What does npm update do?

    Updates all top-level packages respecting the semver specified in package.json, and saves them to package.json (--save-dev or --save are not needed).

  6. What will npm update do? package.json"dependencies": { "dep1": "^1.1.1" }

    Then npm update will install dep1@1.8.3, because 1.8.3 is latest and 1.8.3 satisfies ^1.1.1. "dependencies": { "dep1": "^1.8.3" }

  7. How to update hi to the version "2.0.2"? package.json"dependencies": { "hi": "~1.1.1" }

    npm install hi@2.0.2 --save-dev/--save