I am working on a project which gives cli options to another project. The cli requires some extra dependency which I had listed as devdependency. However, when installed on the target project, the devdependency are not being installed.
npm install
: Installs first level of dev dependency but the dev dependency of a dependency is not installed.
There used to be an option but it was actually a bug and therefore removed. Is there a way to do this now?
NPM installs devDependencies within the package. json file. The 'npm install' command should add all the dependencies and devDependencies automatically during installation. If you need to add specific devDependencies to your project, you can use this command- 'npm install --save-dev'.
When running npm install , it does not install the peer dependencies automatically even if they are in the package-lock. json file. Instead it modifies the package-lock. json file removing all the peer dependencies.
Dev Dependencies: In package. json file, there is an object called as dev Dependencies and it consists of all the packages that are used in the project in its development phase and not in the production or testing environment with its version number.
The difference between these two, is that devDependencies are modules which are only required during development, while dependencies are modules which are also required at runtime. To save a dependency as a devDependency on installation we need to do an npm install --save-dev , instead of just an npm install --save.
If the dependency is required by the target project that is installing it, it should be listed as a dependency. DevDependencies are intended for use only when the module itself is being developed (eg test and packaging tools. )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With