Open fmaclen opened 1 month ago
I don't know that there's anything we can do about this. If your lockfile doesn't have the binary that Rollup is going to choose to use on Cloudflare, then it's just not going to get installed. I do wonder whether you're running into the npm bug mentioned in the error message. Have you tried the workaround mentioned in it?
I do wonder whether you're running into the npm bug mentioned in the error message.
@Conduitry Yeah I created that issue, but I think it's unrelated to the problem I'm describing here.
I understand that we may not be able to do much about the underlying issue but, I was thinking it could be helpful to add a note in the documentation for enhanced-img
that you need to manually set the optional libraries when working with multiple CPU architectures.
Primarily because this means that if you develop on macOS (or any other arm-based system), run SvelteKit's create-app
script, install enhanced-img
and then try to deploy to Cloudflare (and likely other hosting providers too) your build will break with this error.
You don't have to manually set the optional libraries, though, I don't think. You just need to install without a node_modules
directory present. When I cloned your branch, deleted package-lock.json
m and ran npm install
(with no pre-existing node_modules
), a bunch of new platform-specific optional dependencies were added to the lockfile.
I'm -0 about documenting a bug in npm that users will likely already have another way of finding out about. (I think an error message in a build is also more likely to be read by users than a note in the docs, anyway.) (Also this issue is not specific to the enhanced-img
package.) I could be convinced otherwise by other maintainers. But I don't think we want to suggest to users that they manually add optional dependencies to their package.json
. The package.json
is fine - the issue is with the package-lock.json
that npm generates when there is already a node_modules
present and it is missing some optional platform-specific dependencies.
You don't have to manually set the optional libraries, though, I don't think. You just need to install without a
node_modules
directory present. When I cloned your branch, deletedpackage-lock.json
m and rannpm install
(with no pre-existingnode_modules
), a bunch of new platform-specific optional dependencies were added to the lockfile.I'm -0 about documenting a bug in npm that users will likely already have another way of finding out about. (I think an error message in a build is also more likely to be read by users than a note in the docs, anyway.) (Also this issue is not specific to the
enhanced-img
package.) I could be convinced otherwise by other maintainers. But I don't think we want to suggest to users that they manually add optional dependencies to theirpackage.json
. Thepackage.json
is fine - the issue is with thepackage-lock.json
that npm generates when there is already anode_modules
present and it is missing some optional platform-specific dependencies.
Not sure if I had the exact same issue (my dev server crashed after adding the enhanced-img
package) but deleting my node_modules
folder and re-installing did fix it.
Thanks for the tip!
Describe the bug
I'm trying to deploy a project with
@sveltejs/enhanced-img:0.3.0
to Cloudflare. I rannpm i -D @sveltejs/enhanced-img
on a Mac with an ARM-based architecture.When I deploy to Cloudflare (their architecture is x86) and I get the following error during the SvelteKit build process:
The workaround I found is manually setting the x86 variant as an optional dependency in
package.json
.Also, it's not just
@rollup/rollup-linux-x64-gnu
, it's these 3:Reproduction
https://github.com/fmaclen/cloudflare-adapter-dependencies/tree/enhanced-img-issue
Note: the
.node-version
was intentionally set because of this other issue related to Cloudflare: https://github.com/sveltejs/kit/issues/12464Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
No response