The --save
option for npm install
or npm i
allows you to add the npm
module you’re installing
to the file package.json
. This way it’ll become one of the project dependencies and will be
automatically installed the next time you run npm install
.
Let’s take a look at an example and install the module canvas
with the --save
option.
npm install --save canvas
Once you execute the line above in your terminal, the module canvas
will be installed to
node_modules
and a new line will be automatically added to package.json
.
"canvas": "^2.6.1"
Now, canvas
became one of the project dependencies that are tracked in package.json
.
You can learn more about what the caret ^
means next to the version ^2.6.1
here.