Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to npm install only devDependencies with node 8.7.x?

The usual way of installing only devDependencies was to use npm install --only=dev (or --only=production if you want only dependencies).

This doesn't work anymore in 8.7. If I run this command, npm will try installing all dependencies. Or at least, it runs a /usr/bin/git ls-remote -h -t on packages that are not in devDependencies. Those packages being in private git repos, the npm install fails for me.

This didn't happen until I upgraded to 8.7.0, from 7.4.0

The npm cli documentation still shows the old way of doing it though.

Is there a new syntax for that option?

like image 682
nialna2 Avatar asked Oct 16 '25 03:10

nialna2


1 Answers

From the output of npm help install:

npm install (in package directory, no arguments):

Install the dependencies in the local node_modules folder.

In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.

By default, npm install will install all modules listed as dependencies in npm help 5 package.json.

With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies.

So it seems you can install only dependencies with --production; not sure if there's a way to only install devDependencies.

like image 128
RyanZim Avatar answered Oct 17 '25 17:10

RyanZim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!