Reputation: 1268
Want to know the use of -exact
with --save
npm i [email protected] --save-dev --save-exact
Upvotes: 91
Views: 56351
Reputation: 1256
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",
}
When you delete your node_modules
folder and you run npm install
, the versions of the installed packages could get updated when higher ones are available and that can potentially break your application.
For example from 5.1.3
maybe the package is going to be updated to 5.1.8
So, the --save-exact
will generate the next package.json
code
"devDependencies": {
"webpack": "5.1.3",
}
Without the ^
prefix to the version of the package, the installed version will be always the same as specified (here, Webpack version 5.1.3
).
More reference here about semantic version with NPM:
Upvotes: 109
Reputation: 2283
When using save=true
, npm install
will automatically add the package into package.json without the need of using npm install --save
every time you run the command. save-exact=true
will make sure that no sliding versions (with ~
or ^
) will be installed.
reference for more information click here
or please go through this https://docs.npmjs.com/cli/install
Upvotes: 41