npm ci can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1

Solution 1:

After a lot of research, I was able to figure out that this happens when you are not using npm install for installing dependencies. In my case, I was only using yarn for the dependencies so I was only having yarn.lock file and no package-lock.json file.

  • One way to resolve this was using npm install to install the dependencies, then you'll have a package-json.lock file and CI won't throw any error.

  • And the other way if you only want to use yarn, then you need to update that step in your eas-pipeline.yml file for installing the dependencies.

*****************************************************************************************

      - name: Install dependencies
        run: |
          if [ -e yarn.lock ]; then
          yarn install --frozen-lockfile
          elif [ -e package-lock.json ]; then
          npm ci
          else
          npm i
          fi

***************************************************************************************

As I wasn't able to find any solution on StackOverflow and it is our first go-to place to look for the issue. So, I decided to write this answer here.

Here's the original answer: https://github.com/facebook/docusaurus/issues/2846#issuecomment-691706184

Solution 2:

Old post, but I found this while searching for this same error. In my case I did have a package-lock.json file in my root directory. However, when opening it, I realized that there was a JSON syntax error that slipped in during a previous merge conflict. After running npm i again the file was fixed. The npm ERR! The 'npm ci' command can only install with an existing package-lock.json wasn't a super helpful error in that case.