--save
will include a third-party package in the dependencies of your package, ensuring it is installed whenever someone runs npm install yourPackage
.
--save-dev
adds a third-party package to the development dependencies of your package. This means it won't be automatically installed when someone installs your package but can be added when cloning your source repository and running npm install
.
Development dependencies are specifically for tools needed during the development process like test runners, compilers, and packagers.
These dependency types are detailed in the package.json
file, with --save
adding to dependencies
, and --save-dev
adding to devDependencies
. The official npm documentation explains this furtherhere.
devDependencies
If others plan on using your module in their programs, they may not need to download and build external frameworks like testing or documentation tools that you use.
In such cases, organizing these items in a devDependencies object is recommended.
These items will only be installed when running npm link or npm install from the root directory of the package and can be managed like any other npm configuration parameter. Refer to npm-config(7) for more information.
For non-platform-specific build processes (such as converting CoffeeScript to JavaScript), utilize the prepublish script and designate the required package as a devDependency.
Edit: With the release of npm 5.0.0, installed modules are now automatically considered dependencies, rendering the --save option unnecessary.