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

Npm Dependency Installation Fails with ERESOLVE unable to resolve dependency tree #2448

Closed
jGleitz opened this issue Mar 14, 2025 · 0 comments · Fixed by #2449
Closed

Npm Dependency Installation Fails with ERESOLVE unable to resolve dependency tree #2448

jGleitz opened this issue Mar 14, 2025 · 0 comments · Fixed by #2449

Comments

@jGleitz
Copy link
Contributor

jGleitz commented Mar 14, 2025

After we increase the version of prettier in our projects, developers sometimes cannot use spotless at all. They get lint errors on formatted files, informing them that the npm install failed:

There were 39 lint error(s), they must be fixed or suppressed.
  build/<path to SQL file>:LINE_UNDEFINED prettier-format(com.diffplug.spotless.npm.NpmProcessException) Running npm command 'NpmInstall in <project path>/build/spotless-prettier-node-modules-edd532637edcb6904b3d70deaa4ddaa0 [<project path>/.gradle/nodejs/node-v22.14.0-darwin-arm64/bin/npm install --no-audit --no-fund --prefer-offline]' failed with exit code: 1 

Reproducing the command spotless runs reveals the error by npm spotless is facing:

npm install error
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: spotless-prettier@2.0.0
npm error Found: prettier@undefined
npm error node_modules/prettier
npm error   dev prettier@"3.4.2" from the root project
npm error
npm error Could not resolve dependency:
npm error peer prettier@"^3.0.3" from prettier-plugin-sql@0.18.1
npm error node_modules/prettier-plugin-sql
npm error   dev prettier-plugin-sql@"0.18.1" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error <user home>/.npm/_logs/2025-03-14T09_43_53_020Z-eresolve-report.txt
npm error A complete log of this run can be found in: <user home>/.npm/_logs/2025-03-14T09_43_53_020Z-debug-0.log

The root problem is that npm needs to update its package information, but doesn’t do that when --prefer-offline is set. Spotless already has logic for such a case, but the detection for when to apply that logic does not include this case, yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant