What is the purpose of using –save-exact

For example, I use --save-exact when I manage projects with webpack.
As you know, when you install a package like npm install --save-dev webpack for example, our package.json will add something like:

"devDependencies": {
    "webpack": "^5.1.3",
}

What does it mean?

When you delete your node_modules folder (for example when you put your files on github)and you make a npm install, maybe a version of any package could be updated and if the version is not a major version (X.0.0), Maybe your application stops working because of update. For example from 5.1.3 maybe the package is going to uptade to 5.1.8

So, the --save-exact will generate the next package.json code

"devDependencies": {
    "webpack": "5.1.3",
}

Whitout the ^, the version of the package of webpack in this case will be always the same 5.1.3.

More reference here about semantic version with NPM:

  • About semantic versioning

PDT: Sorry for my poor English.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)