esbuild: "The package "esbuild-linux-64" could not be found, and is needed by esbuild."
We are using SvelteKit, which uses Vite, which uses esbuild and we are seeing this error on some of our macs.
We also have devs on linux who are not having this issue.
I was able to find this, but it’s closed with little to no explanation: https://github.com/vitejs/vite/issues/5187
Could this be caused by installing things on a linux machine, package-lock.json gets some notions, and then it’s a problem on other platforms? Is something else going on? Happy to be pointed in another direction if this isn’t specifically an esbuild issue.
npm ls
output from my linux machine indicates the following versions:
─┬ vite@2.6.14
├── esbuild@0.13.15 deduped
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 45 (7 by maintainers)
Commits related to this issue
- attempt a better x-platform error message (#1819) — committed to evanw/esbuild by evanw 2 years ago
- Fix package-lock.json for knowage-vue See: https://github.com/evanw/esbuild/issues/1819#issuecomment-1509712215 — committed to KnowageLabs/Knowage-Server by kerny3d a year ago
- Try removing package-lock.json to work around https://github.com/evanw/esbuild/issues/1819 — committed to rewbs/butterchurn-recorder by deleted user a year ago
- chore(webpack): attempt to avoid esbuild blob prob See https://github.com/evanw/esbuild/issues/1819 — committed to LavaMoat/LavaMoat by boneskull 8 months ago
- chore(webpack): attempt to avoid esbuild blob prob See https://github.com/evanw/esbuild/issues/1819 — committed to LavaMoat/LavaMoat by boneskull 8 months ago
For anyone else like the OP who is using SvelteKit + Vite and also deploying on Vercel, I solved the following error simply by deleting
package-lock.json
and adding it to.gitignore
I’m going to try improving the error message in the situation where you have installed esbuild for a different platform than the one you’re currently on. The error message I added looks like this:
Edit: And it’s also now documented on the website too: https://esbuild.github.io/getting-started/#simultaneous-platforms
This error suddenly started consistently happening to me in Netlify deploys using Vite without me having made any config or dependency changes.
Re-generating
package-lock.json
fixed it, and I have no idea why 🤷edit Here’s a full command since I keep coming back here:
This happened to me because I had
--ignore-scripts
on my npm commandFWIW we had the same issue with yarn 2 version berry. Since with Yarn 2, you can use zero installs which makes you commit the
.yarn/cache
folder (which is similar to node_modules).Turns out adding this to our .yarnrc.yml file solved it as described here (tailor to what architecture you want to support): https://yarnpkg.com/configuration/yarnrc#supportedArchitectures
I noticed this issue when I ran an
npm prune
locally.I’m on Windows, so the prune removed the cross platform packages from my
package-lock.json
. Then when the project was installed/built in GitHub actions (running on Linux) the build blew up because the linux binaries were missing.Removing my
node_modules
, deletingpackage-lock.json
and re-installing the dependency got everything working for me.If you run into this issue, look at the diff of the
package-lock.json
compared to the last time the build worked and also check if you are building on a different OS than you updated thepackage-lock.json
on.I’m getting the same error when running esbuild on Vercel in a serverless function. In vercel/vercel#7287 I linked to my repository along with the deployment showing the error, but the complication is that the problem isn’t happening locally, only in the deployment, so I’m not sure where it goes wrong and how to go about debugging it. It’s probably a question for them, but I thought that cross-linking this issue couldn’t hurt.
Just adding our experience here…
We have a shared volume containing the
node_modules
from our developer’s mac machines to our numerous linux Docker containers. We can run the install from inside the containers to bypass this, but it’s prohibitively slow due to the size of the containers compared to the host machine.It runs fine on the few non-mac machines we have which are both running linux.
Unfortunately the outputted suggestion for the additions to
.yarnrc.yml
doesn’t work either, as Yarn stubbornly will continue to detect the platform and not link thesupportedArchitectures
which are not in the current architecture/platform:esbuild-linux-64@npm:0.14.14 The linux-x64 architecture is incompatible with this module, link skipped.
Yarn Classic used to have the option to pass the
--ignore-engines
flag which likely would have been a nice workaround, but in Yarn 2 this is deprecated, and I have not found another way to bypass the platform checks in Yarn 2.This has just started destroying my vercel builds in a project that has worked for years. Very surprising and hard to solve as removing package-lock.json and the node_modules folder has not helped.
Edit: After another try it works.
Thank you for the quick response.
I deleted
package-lock.json
on a MacOS and a Linux machine, then rannpm install
on both (npm version 9.2.0). I got 2 radically different lock files, which really puzzled me.When I looked at the diff, I saw something very strange however. One of the lock files had:
even though the
package.json
specified"esbuild": "^0.16.17",
. The linux one did not contain this. Very strange.I then decided to fully delete the
node_modules
folder on both machines andnpm cache clean -f
, then runnpm install
again.This time, the listing of
esbuild-darwin-arm64
was gone, and the lock files were identical.Not sure I understand why the generation of
package-lock.json
depends on either, but that might be a question for the npm team.Thank you for a fantastic package, and my apologies for wasting your time.
@james-innes’s workaround works great, but the real question is…
Why is esbuild adding the platform-specific package to
package-lock.json
? Isn’tpackage-lock.json
supposed to be version-controlled, and hence supposed to be platform-independent?If I’m on MacOS, and my colleague is on Windows, we will be generating different
package-lock.json
files, and our CI system, which might be some flavor of Linux, won’t runnpm ci
because the wrong platform-specific version of esbuild is getting installed.Is there any way to avoid the platform-specific esbuild package from ending up in
package-lock.json
in the first place?I’m geting this error in linux based docker image. Even after
npm i esbuild-linux-64
I simply had to delete the node_modules folder and reinstall
That sounds rather wrong.
AFAIK no one in the world copies the “node_modules” directory (!!!)
What people often do (especially in CI/CD) is to rely on package_lock.json (which is, in this scenario, commited to git) to avoid running “npm install” and doing instead “npm ci” (the description above seem to confuse these two very different commands)
“npm ci” respects the concrete dependencies listed in package_lock.json, while “npm install” recomputes them. The advantages of “npm ci” are speed and reproducibility. And it’s the normal way to do automated deploys in dockerized instances.
To anyone who wants to fix this, but does not want to remove
--ignore-scripts
for all packages, Runningnpm install esbuild
afternpm ci --ignore-scripts
fixes the issue.Two options that works on gitlab’s docker compose (node:20-buster)
№1
№2
I copied the built module from inside the container into the
.yarn
directory then referenced it like so in my package.json.Thank you @evanw , installing node through nvm instead of the installer from the site did the trick 👍🏻
I’m going to close this issue because it has been marked as
unactionable
for a while and specific steps to reproduce the issue from scratch haven’t been provided. This issue can definitely be reproduced by copying anode_modules
folder from one OS to another without reinstalling, but your not supposed to do that. There should now be a specific error message when that happens with workarounds and workarounds are also described on the website. It’s unclear if this is what’s happening in all of these cases or if something is going on in other cases, but we won’t know unless specific reproduction steps are provided for the other cases. I think these are probably best filed as new issues instead.I created the most basic setup I could here: https://github.com/andyburke/esbuild-bug-linux-mac
I’ll try to ask a colleague with a mac to pull and test it to see if they can repro the problem. If anyone here has a mac, maybe they could try as well.