npm Community Forum (Archive)

The npm community forum has been discontinued.

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

npm ci and optional packages

We are working on our first project using nodejs.

We have in our package.json Cypress in the optional packages.

For stability we want to use npm ci instead of npm install. But the --no-optional seems not to work.

How could I manage this?



2019-02-12 Update: Finally we are using yarn. npm seems still to have too many little problems.

Hi Olivier, have you read the npm CLI docs about npm ci? npm ci was designed to be used by automation platforms, like Jenkins for example. There’s nothing wrong with using it locally I suppose. The project must already have a package-lock.json or npm-shrinkwrap.json in order for the command to work.

I ran npm ci --no-optional in one of my local repos with npm@6.5.0 and was unable to reproduce an error, but this project had an existing package-lock.json.

Hi Brian,

Maybe I was not clear enough. We are deploying in Azure using automated environment that’s why we want to use ci so we are sure about the packages versions used (had problems several times already using install).

For the tests we are using Cypress (actually in the optional dependencies). But in our production environment it is not needed and it consumes time and space.

Some ideas? Thanks.
Kind regards

Ah I see. So in your production builds you’re running npm ci --no-optional but Cypress is still being installed? That does sound a little buggy to me since it exists as an optional dependency, but it shouldn’t impact the size of deployables. Don’t you want to run the test cases in a production build anyway?

Hi Brian,

No, we don’t since the site is published as non static, and having the cypress makes the build be 10 minutes longer.

Well, my other suggestion would be to disable running the tests during the production build, and then you can open a ticket on the bug you reported in Github.

The npm ci bug would go in #bugs, not on GitHub (if you meant that).