When I am in a Node.js project and run npm install
, npm installs both, dependencies and dev dependencies. If I do not want to install the dev dependencies, I can run npm install --production
.
Question 1: If I do not provide --production
: Are the dependencies' dev dependencies installed, too, or only their actual dependencies?
Now, what if I am in a Node.js project and install a new dependency, something such as:
npm install foo
This installs foo
's dependencies, of course.
Question 2: But what about its dev dependencies? Are they installed, too, or are they skipped?
npm install downloads a package and it's dependencies. npm install can be run with or without arguments. When run without arguments, npm install downloads dependencies defined in a package. json file and generates a node_modules folder with the installed modules.
A: Both dependencies and devDependencies are installed to the local node_modules folder on a yarn install or npm install , but only dependencies - and not devDependencies - are installed to the local node_modules folder when doing a yarn install --production and npm install --production .
A dev dependency is a package used during development only. To remove a dev dependency, you need to attach the -D or --save-dev flag to the npm uninstall, and then specify the name of the package. You must run the command in the directory (folder) where the dependency is located.
This uninstalls a package, completely removing everything npm installed on its behalf. It also removes the package from the dependencies , devDependencies , optionalDependencies , and peerDependencies objects in your package. json .
Answers to your questions:
npm install
only way it wont install dev dependencies is when NODE_ENV
is set to production
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