PASSWORD RESET

Your destination for complete Tech news

What is the difference between –save and –save-dev?

761 0
< 1 min read

When installing a package using npm (the package manager for Node.js), you can use the --save flag to add the package to your project’s dependencies in the package.json file. This indicates that the package is required for your project to run and should be installed when running npm install.

On the other hand, the --save-dev flag adds the package to your project’s devDependencies in the package.json file. This indicates that the package is only needed for development, such as for testing or building, and should not be included in the production environment.

For example, if you are installing a testing library like Mocha, you would use the --save-dev flag, because you don’t need the testing library to run the production version of your app. On the other hand, if you are installing a library like Express, which is required for your app to run, you would use the --save flag.

Here’s an example of installing a package with the --save flag:

npm install express --save

And here’s an example of installing a package with the --save-dev flag:

npm install mocha --save-dev

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.