What are dependencies and devDependencies in package.json and what is the difference between them?

Experience Level: Junior
Tags: npm

Answer

Dependencies are packages that the project uses at runtime. Which means they need to be installed for the program to be able to run. Without them the project won't work.

devDependencies are packages that are used during development of the project. They help a developer to achive some task. As an example, a devDependency can be:

  • web server (so that a developer can run the web application locally)
  • minifier (so that the build process can strip out unnecessary white-spaces and redundant characters from the JavaScript/CSS files)
  • uglifier (so that the build process can make the JavaScript files less readable for the people who might be trying to reverse-engineer your program)
  • bundler (so that the build process merges multiple JavaScript files into one)

devDependencies are helpful during the development and build process. They are not needed for the program to run.

Comments

No Comments Yet.
Be the first to tell us what you think.
npm for beginners
npm for beginners

Are you learning npm ? Try our test we designed to help you progress faster.

Test yourself