Skip to content

npm dependency resolution error with Symfony-provided package.json file #246

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

Open
mbtuckersimm opened this issue May 19, 2025 · 1 comment

Comments

@mbtuckersimm
Copy link

My app is using Symfony 5.4 because we are still stuck on an ancient version of PHP (7.2.24, currently). We are using Symfony Flex. I ran

composer require symfony/webpack-encore-bundle

which resulted in webpack-encore-bundle v1.17.2 being installed.

Then, when I ran npm install to install the dependencies, I got this error in dependency resolution:

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @symfony/webpack-encore@4.7.0
npm error Found: @symfony/stimulus-bridge@4.0.1
npm error node_modules/@symfony/stimulus-bridge
npm error   dev @symfony/stimulus-bridge@"^4.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peerOptional @symfony/stimulus-bridge@"^3.0.0" from @symfony/webpack-encore@4.7.0
npm error node_modules/@symfony/webpack-encore
npm error   dev @symfony/webpack-encore@"^4.0.0" from the root project
npm error
npm error Conflicting peer dependency: @symfony/stimulus-bridge@3.2.3
npm error node_modules/@symfony/stimulus-bridge
npm error   peerOptional @symfony/stimulus-bridge@"^3.0.0" from @symfony/webpack-encore@4.7.0
npm error   node_modules/@symfony/webpack-encore
npm error     dev @symfony/webpack-encore@"^4.0.0" 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.

The package.json file that appears when I run the composer require command includes these two lines:

"@symfony/stimulus-bridge": "^4.0.0",
"@symfony/webpack-encore": "^4.0.0",

which are what's causing the problem, since webpack-encore v4.7.0 declares a dependency on stimulus-bridge ^3.0.0.

What's going on here? I didn't change the package.json at all. Is there something about my configuration that's resulting in Symfony providing a requirements file with conflicting dependencies? Is there some way to fix it?

@stof
Copy link
Member

stof commented May 19, 2025

Looks like symfony/recipes#1378 was wrong, by not respecting the peer dependency of webpack-encore.

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

No branches or pull requests

2 participants