Welcome to the Linux Foundation Forum!

semver package question

jhonny111s
jhonny111s Posts: 22
edited November 2021 in LFW211 Class Forum

I have been trying to understand how works npm i, how works caret and tilde but I don't know why I can not save with the command npm i a tilde or other any expression of semver.

The semver prefix is defined by the save-prefix config. The default value is a caret (^) which you can check by running the following npm config command:

npm config get save-prefix

npm i pino@6.x.x save in package.json ^6.13.3
npm i pino@"~6.11" save in package.json ^6.11.3
npm i pino@"6.11.x" save in package.json ^6.11.3

the only way to see what i want is update manually my package.json

 "dependencies": {
    "pino1": "^6.11.1"
    "pino2": "~6.11"
    "pino3": "6.x.x"
    "pino3": "6.11.x"
  }

Comments

  • jhonny111s
    jhonny111s Posts: 22
    edited November 2021

    i tested all here: https://semver.npmjs.com/

    ~version “Approximately equivalent to version”, will update you to all future patch versions, without incrementing the minor version. ~1.2.3 will use releases from 1.2.3 to <1.3.0.
    ^version “Compatible with version”, will update you to all future minor/patch versions, without incrementing the major version. ^2.3.4 will use releases from 2.3.4 to <3.0.0.
    
  • hi @jhonny111s

    • npm install doesn't support the syntax you're trying to use
    • the semver save prefix is a configuration option, not a command-line flag
    • editing the package.json is the way to specify more nuanced versioning strategies

Categories

Upcoming Training