The --save
option for npm install
is used to save the installed package as a dependency in the package.json
file of the project.
By default, npm install
installs a package in the local node_modules
directory, but does not update the dependencies
section of the package.json
file. This means that the installed package will not be listed as a dependency of the project, and it will not be included when the project is published or when another developer installs the project’s dependencies.
To save the installed package as a dependency of the project, you can use the --save
option when running npm install
. For example:
npm install express --save
This will install the express
package in the local node_modules
directory, and it will also update the dependencies
section of the package.json
file to include express
as a dependency.
You can also use the --save-dev
option to save the package as a development dependency, which is useful for packages that are only needed during development, such as testing frameworks or build tools.