npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Workaround for `npm ci –no-optional` which still installs optional dependencies

I had created a bug report but was referred to the support area of the forums because I’m also looking for a workaround.


What I Wanted to Do

I expected npm ci --no-optional to skip optionalDependencies .

What Happened Instead

It didn’t.

More info

Originally I the problem appeared with npm 6.4.1 but I tried using latest npm version and also deleting my lock file and letting latest npm version re-create it but the problem persists.

An obvious work-around is to use npm install --no-optional instead of ci?

How is that an obvious workaround? This is times slower and cant be used for the CI purpose. Effectively is not a workaround

Assuming your goal is a reproducible install of a package, but without the optional dependencies, then this is an easy work-around for npm ci not working for that case. (I’m not suggesting it as an exact performance replacement.)