Closed EMH333 closed 1 month ago
I'm not sure if I'm doing something wrong, but I'm seeing this when I run
npm install
.$ npm install npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: project@undefined npm ERR! Found: svelte@5.0.0-next.136 npm ERR! node_modules/svelte npm ERR! dev svelte@"^5.0.0-next.136" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer svelte@">=3.43.0 <6" from esbuild-svelte@0.8.1 npm ERR! node_modules/esbuild-svelte npm ERR! dev esbuild-svelte@"^0.8.1" from the root project
My
package.json
looks like this.{ "name": "project", "devDependencies": { "esbuild": "^0.21.0", "esbuild-svelte": "^0.8.1", "svelte": "^5.0.0-next.136" } }
I updated to the latest
esbuild-svelte
and installedsvelte@next
.
TL;DR: Use --force
or --legacy-peer-deps
for the prereleases since there isn't a great way to allow peer dependencies of all prerelease versions of a package.
Essentially, semver doesn't consider prereleases of v5 to be <6
. As a result, even though the human-readable version number of 5.0.0-next.1
is clearly less than v6
, semver doesn't consider that to be the case (try it out with https://semver.npmjs.com/). This means that dependency graph solving fails.
There are numerous issues about this (https://github.com/npm/cli/issues/2087 as an example) and an active RFC on how to resolve this https://github.com/npm/rfcs/pull/397.
But I don't think there is a clear/easy way to fix this for the prerelease versions. This won't be an issue once Svelte 5 is officially released.
Excellent! Thanks for the detailed answer! I didn't realize this was a known behavior with npm. Good to know. Adding --force
worked! Project builds and runs fine now.
Would it make sense to change esbuild-svelte's package.json to this?
"peerDependencies": {
"esbuild": ">=0.9.6",
- "svelte": ">=3.43.0 <6"
+ "svelte": ">=3.43.0 <5 || ^5.0.0-next.0"
},
Then later, when Svelte 5 officially releases, maybe you could do this?
"peerDependencies": {
"esbuild": ">=0.9.6",
- "svelte": ">=3.43.0 <5 || ^5.0.0-next.0"
+ "svelte": ">=3.43.0 <5 || ^5.0.0-next.0 || ^5.0.0"
},
I think this could improve the DX by not requiring that users pass --force
to npm install
. Also, this is how svelte-check does it.
Interesting! Let me play around with that and see what I can do
The change to allow Svelte 5 pre-releases as a peer dependency has been released as v0.8.2
. Sorry for the delay!
Svelte 5 has officially been released, meaning esbuild-svelte will no longer provide support or compatibility for prereleases. Closing this issue.
This is different than #234 since npm does some funny things with version locks and the prerelease versions may have subtle changes compared to the actual release.
This is a good time to clarify my commitment to prerelease support:
esbuild-svelte
will have an installable version compatible with Svelte 5 the day it is released. It may not support all the new features, but it will at least let projects compile with Svelte 5. Worth noting that I am intendingv0.8.1
to be that version, but won't hesitate to make changes as required.