DEV Community

Dana Woodman
Dana Woodman

Posted on • Updated on

Include (or omit) Node.js devDependencies in your CI environment

UPDATE: It's actually simpler to use npm ci instead of npm install because it installs devDependencies too and is actually more efficient. Hat tip to Lucian 🍻

Ever need to install your devDependencies in a CI environment but the environment wants to install only dependencies? Here's how to fix it:

npm install --include=dev
Enter fullscreen mode Exit fullscreen mode

You can also omit dependencies with the --omit=... flag.

You can use the options dev, optional and peer in both these flags.

Hope that saves you a few minutes, as it did me! 🍻

Hat tip to Ben McCann on the Svelte Discord for pointing me in the right direction!

Follow me on, Twitter and Github for more web dev and startup related content 🤓

Top comments (3)

lil5 profile image
Lucian I. Last • Edited

What are your opinions comparing this method npm install --only=prod with npm ci?

I found that npm ci --only=prod works as well (see link)

danawoodman profile image
Dana Woodman

You're correct. npm ci also installs dev dependencies.

Adding --only=prod or --production would not install devDependencies and just install dependencies.

I'll update the article to show both options 👍

jef profile image
Jef LeCompte

It's now recommended to use --omit=dev over --production 😆 Good ole Node.js.