When I initialize npm init and install the dependencies, I would like to know what is the difference between dependencias de desarrollo
and dependencias
?
When I initialize npm init and install the dependencies, I would like to know what is the difference between dependencias de desarrollo
and dependencias
?
The devDependencies
are dependencies that you use only for the development phase commonly, tranpiles taskrunner and unit test are handled as devDependencies
ej. grunt gulp babel mocha chai etc. these dependencies are not necessary in production and your application can work if they do.
The dependencies
are what you use so that your project works e.j express monngoose lodash body-parser these dependencies are part of the logic of your application and are necessary for the project to work properly in production.
A developer dependency is a dependency that is only used in the development phase
For example it is normal to give your application a documentation or manuals, however users usually require manuals in different formats eg texto plano
, html
, or pdf
. In practice, it is annoying to have to develop documents with the same information, so you resort to an application that generates a single file, the documents .txt
, .html
, .pdf
. We say then that our project depends on that application to generate the documentation, however the project itself does not require the application to be executed, this is called developer dependency
.
Another example:
In compiled languages, other applications are usually required to compile your project, for example, many use make
, without them you will not be able to compile the project, however your project does not depend directly on it, it only depends on it in the phase of compilation but not in its execution.
In general
A developer dependency is one that you depend on in the development phase but not in the execution / distribution phase
In node
, a dev dependency
could be less
, with less
you would generate style sheets for your web application, however when you upload your web application to production you only upload the .css
generated files by less
, as you can see your project does not depend on less
in the execution / distribution phase.
Another example in node
of dev dependency
could be babel.js
, with babel.js
you would translate your .js
of ECS6
to ECS5
notwithstanding once transladados de standard, the use of babel.js
is debatable, therefore babel.js
is only a dev dependency