Category: CRM and lead management

npm ci Fails in CI Because the Lockfile Is Incompatible

Read this guide in Polish

The e.g. command is intentionally more stringent than e.g. install. In the production pipeline requires consistent package.json and package-lock.json and does not repair them in flight. Therefore, the project may operate locally but not build in CI.

How to Recognize Cause

Open the first e.g. error in CI logs and save its exact content. Distinguish no package in lockfile from peerDependenties conflict and from Node version error or e.g.

Compare package.json and package-lock.json in the commission selected for construction. Remember that local node modules may contain remnants of packages that are not in dependencies files.

Step by step solution

1. Start by making sure that you work on the right branch and have no unwritten changes. Check git status and differences in package.json and package-lock.json.

2 . Run egm install in a controlled environment with compatible Node version and egm to play the correct package-lock.json file. It does not automatically remove the cause of conflict of incompatible versions.

3 . Run a clean installation e.g., preferably in a separate working directory or after the safe removal of local dependencies. Do not perform destructive cleaning in a directory with unsaved code.

4 . If the problem concerns peer defaulters, identify specific packages and match their versions. Flag legacy-peer-deps can mask conflict and should be a conscious, coherent decision rather than a first response.

5 . Save and push the compatible lockfile together with package.json, then repeat CI. Check whether the pipeline uses the same main Node version as the local environment.

How to see if the problem is gone

The course of e.g. should end without error, and after it should pass typecheck, tests and production build. The correct installation itself does not guarantee the correct application.

On a new branch or a clean clown run the same sequence of commands as CI to ensure that the result does not depend on the random content of node modules.

What to do

Do not add node modules to the repository and do not delete package-lock.json just to disable the conflict. You're going to lose the reproducibility of the installation.