Want to know the use of -exact
with --save
npm i [email protected] --save-dev --save-exact
The --save option instructed NPM to include the package inside of the dependencies section of your package. json automatically, thus saving you an additional step.
The npmrc manages the npm config files. The config setting for npm is gotten from the command line, environment variables and the npmrc files. You can use the npm config command to update and edit the contents of the user and global npmrc files.
@Kokodoko When you use the --save-dev flag, the package is added to your devDependencies object. If/when someone installs your package, all the dependencies are downloaded but the devDependencies are not, since they aren't required at runtime. As the answer stated, this saves them time and space.
You don't need --save anymore for NPM installs. This was long the golden standard to install a package and save it as a dependency in your project. Meaning if we didn't specify the --save flag, it would only get locally installed and not added to the package.
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 (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:
PDT: Sorry for my poor English.
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 not be installed.
reference for more information click here
or please go through this https://docs.npmjs.com/cli/install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With