3

If a package.json file has an engines field like this:

    "engines" : {
      "node" : "~>12"
    },

What does the ~> mean?

dagda1
  • 26,856
  • 59
  • 237
  • 450
  • 1
    It doesn't make sense to me. `~12` means `12 <= (~12) < 13` and `>12` means any version higher then 12. So using both `~` and `>` seems wierd. But i might be wrong though. [See this](https://stackoverflow.com/questions/22343224/whats-the-difference-between-tilde-and-caret-in-package-json) – Molda Apr 05 '21 at 10:33

1 Answers1

2

engines Sets which versions of Node.js and other commands this package/app work on

example:

"engines": {
    "node": ">= 6.0.0",
    "npm": ">= 3.0.0",
    "yarn": "^0.13.0"
}

So if you see ~>12.0.1 it means to install version 12.0.1 or the latest patch version such as 12.0.4

Masood
  • 1,545
  • 1
  • 19
  • 30
  • sorry I meant specifically the `~>` mean, I have updated the question. – dagda1 Apr 05 '21 at 10:19
  • I updated my answer as well and hope you will find it useful. – Masood Apr 05 '21 at 10:22
  • do you have a link for this, I cannot find it in any docs. There was something similar in ruby but I've not seen in a package.json before. – dagda1 Apr 05 '21 at 10:38
  • https://michaelsoolee.com/npm-package-tilde-caret/#:~:text=npm%20uses%20the%20tilde%20(~),means%20to%20install%20version%201.0.&text=json%20file%20you're%20referencing,only%20grab%20the%20patch%20version. – Masood Apr 05 '21 at 10:39