Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm ci validates package-lock.json that is generated with an older version of npm and fails to resolve #5125

Closed
2 tasks done
irdkwmnsb opened this issue Jul 5, 2022 · 8 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@irdkwmnsb
Copy link

irdkwmnsb commented Jul 5, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

package-lock.json generated prior to 8.6.0 is generating package-locks that the new version cannot resolve:

npm ERR! code EUSAGE
npm ERR! 
npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm ERR! 
npm ERR! Invalid: lock file's type-fest@0.21.3 does not satisfy type-fest@0.13.1
npm ERR! Missing: type-fest@0.21.3 from lock file
npm ERR! 
npm ERR! Clean install a project
npm ERR! 
npm ERR! Usage:
npm ERR! npm ci
npm ERR! 
npm ERR! Options:
npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
npm ERR! [--script-shell <script-shell>]
npm ERR! 
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR! 
npm ERR! Run "npm help ci" for more info

Common libraries like create-react-app use @ pmmmwh/react-refresh-webpack-plugin library which has a dependency of type-fest@0.13.1. Version of npm prior to 8.6.0 would not include type-fest@0.13.1 in the package-lock.json

After the 8.6.0 release, old package-locks would not work for installing dependencies with npm ci

Expected Behavior

npm ci should not fail with lockfiles generated by older version npm

Steps To Reproduce

See this commit tree for an example of a project with a lockfile that is valid for an old version of npm and not valid for new ones.

Run npm ci with npm version 8.6.0 or higher to get the error or see this github actions pipeline

Environment

  • npm: 8.13.2
  • Node.js: 16.15.1
  • OS Name: ubuntu-latest
  • System Model Name: Github actions runner
@irdkwmnsb irdkwmnsb added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Jul 5, 2022
@irdkwmnsb
Copy link
Author

irdkwmnsb commented Jul 5, 2022

Resolvement

Running npm i with a new version of npm and committing the relevant package-lock.json resolves this issue.

But if there was a bug in checking the dependency tree, shouldn't the users see a link to #5113 on how to resolve their issue when they encounter it?

Opening an issue here so other people that might encounter this exact issue can google it.

@irdkwmnsb irdkwmnsb changed the title [BUG] npm i doesn't solve all peer dependencies [BUG] npm ci validates package-lock.json that is generated with an older version of npm and fails to resolve Jul 5, 2022
@eyalroth
Copy link

eyalroth commented Jul 6, 2022

Happening for us too and currently breaking our CI builds on multiple repositories.

Edit:

Running npm i with a new version of npm and committing the relevant package-lock.json resolves this issue.

This workaround seems to work.

@mkesavan13
Copy link

Broke our CI builds too. Thanks @irdkwmnsb. Your workaround helped and have worked out for us too.

@wraithgar
Copy link
Member

Please see pinned issue #5113

@irdkwmnsb
Copy link
Author

irdkwmnsb commented Jul 14, 2022

Please see pinned issue #5113

@wraithgar
Why not include a link to that issue with the validation error?
I was only able to find the issue because I wanted to file a bug report, which most developers won't be doing.

orenyomtov added a commit to fireblocks/fireblocks-web3-provider that referenced this issue Aug 31, 2022
MoYeonWook added a commit to WebBlogProject/web-blog-frontend that referenced this issue Nov 29, 2022
package 및 package lock이 동기화가 되지 않아 'npm ci' 수행 시 오류 발생.
npm install로 동기화 진행.
커밋 이후에도 다른 환경에서 'npm ci'가 수행되는지 확인 필요.
참고 페이지 :npm/cli#5125

관련: #10
MoYeonWook added a commit to WebBlogProject/web-blog-frontend that referenced this issue Nov 29, 2022
package 및 package lock이 동기화가 되지 않아 'npm ci' 수행 시 오류 발생.
npm install로 동기화 진행.
커밋 이후에도 다른 환경에서 'npm ci'가 수행되는지 확인 필요.
참고 페이지 :npm/cli#5125

관련: #10
MoYeonWook added a commit to WebBlogProject/web-blog-frontend that referenced this issue Nov 29, 2022
'npm ci' results an error because package-lock.json and package.json were
not synchronized. Therefore, 'npm install' was done.
reference: npm/cli#5125

related: #10
MoYeonWook added a commit to WebBlogProject/web-blog-frontend that referenced this issue Dec 10, 2022
'npm ci' results an error because package-lock.json and package.json were
not synchronized. Therefore, 'npm install' was done.
reference: npm/cli#5125

related: #10
@CalvinJamesHeath
Copy link

CalvinJamesHeath commented Mar 25, 2023

Irdkwmnsb, that was the only workaround for me out of all the options! I ran npm install after removing the package-lock.json file and node modules. Along with checking all dependencies for obsolete ones, several dependencies were also upgraded to the most recent version. It took me five hours to fix as I couldnt update my Firebase Cloud Functions.

I was getting the following 6 errors (with command firebase --debug deploy) : {

  1. npm err! npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync.
    2.Invalid lock file's typescript@version does not satisfy typescript@version
    3.Error code EUSAGE
    4.Could not find image for function projects/etc/etc
    5.Missing URI for HTTPS function in printTriggerUrls. This shouldn't happen.
    6."Invalid source token" code 9
    }

THE SOLUTION FOR EVERYTHING 🥁(drumroll...)(MAC OS USES SUDO)

Npm will always use the version of npm installed with node. If you are running node update node first running:

$ sudo npm install -g n

(And to install the latest stable node release)

$ sudo n latest

And then check your npm version again - it should be updated. (npm -v)

Thank you so much!

konovalovsergey added a commit to ONLYOFFICE/build_tools that referenced this issue Aug 16, 2023
… web-apps"

This reverts commit 5012e4e.
because error with npm ci (-v 9) on package-lock.json(-v 6) file with local dependencies
npm/cli#5125
npm/cli#529
@juane1000
Copy link

The suggested workaround also worked for me when trying to update firebase cloud function that serves a Nuxt app using Firebase CLI framework functionality. Delete the initial package-lock.json, updated npm (cause why not), and ran npm install. Deploy worked finally.

@robot-88
Copy link

robot-88 commented Feb 8, 2024

I tried deleting my package-lock.json and executed npm i, still my pipeline is failing. Can any one help?

name: CI/CD

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
  matrix:
    node-version: [18.x]
    # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
  uses: actions/setup-node@v3
  with:
    node-version: ${{ matrix.node-version }}
    cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

7 participants