What's the difference between a NPM dependency and devDependency?

Answered
coderguy asked this question 8 months ago
coderguy on Dec 2, 2021

In the NPM package.json file, there are dependencies and devDependencies listed.

What's different about these two types of dependencies?

1 suggested answers
itsbambi on Dec 9, 2021

Short explanation:

  • dependencies: a list of NPM packages that an application needs at runtime.
  • devDependencies: a list of NPM packages that an application only needs in development or testing environments.

You install a dependency with this command:

npm install <package> --save

This will add the package and it's version number to the "dependencies" section of your package.json file.

You can install a devDependency with this command:

npm install <package-name> --save-dev

This will add the package to the "devDependencies" section of the package.json file.

0 replies
Answered