-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
"The package "esbuild-linux-64" could not be found, and is needed by esbuild." #1819
Comments
Do you have an steps that can be followed to reproduce this issue? |
Unfortunately, this is a difficult one to figure out a repro on. I am suspicious it would read like:
I can try to create a bare project on linux and point people at it, but I can't easily test this on a mac myself. |
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. |
Yeah, so pulling the The darwin version is installed as expected. |
Ok, good to know. Marking this as |
Just saying +1 to this issue without providing specific reproduction instructions isn't adding any additional information. Please provide specific end-to-end instructions for how to reproduce the issue. |
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. |
I experienced this issue in some situations where we had a Yarn cache from gems installed on the wrong CPU architecture (Docker images built on a Mac with Apple Silicon then pushed up to run on Linux on x86). In every instance we encountered this, it was because we had shared |
This could make sense, we run our containers on linux images, but for development we mount our local filesystems into the containers, sometimes those local filesystems are running on Mac, for instance. Is there some way to have ESBuild install for multiple platforms somehow? |
I'm geting this error in linux based docker image. Even after |
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 |
I'm going to close this issue because it has been marked as |
Just adding our experience here... We have a shared volume containing the It runs fine on the few non-mac machines we have which are both running linux. Unfortunately the outputted suggestion for the additions to
Yarn Classic used to have the option to pass the |
FWIW we had the same issue with yarn 2 version berry. Since with Yarn 2, you can use zero installs which makes you commit the 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'm having the same problem with our M1 macs. We are not sharing node modules at all. Any chance we can give this a look over? |
One idea: are you perhaps running an x86-64 node executable? Apple lets you run x86-64 executables through Rosetta. If so, a fix for this could be to try installing the native version of node instead. |
Thank you @evanw , installing node through nvm instead of the installer from the site did the trick 👍🏻 |
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 "npm ci" respects the concrete dependencies listed in package_lock.json, while "npm install" recomputes them. |
FYI this fix solved issues that I had on Circle CI when using Yarn 2/berry PNP. thanks |
@cobyrne09 This is the issue we are running into now. Did you ever find a solution? |
I copied the built module from inside the container into the
|
This also happens when yarn sets a different "node_modules" directory using |
For anyone else like the OP who is using SvelteKit + Vite and also deploying on Vercel, I solved the following error simply by deleting
|
@james-innes's workaround works great, but the real question is... Why is esbuild adding the platform-specific package to If I'm on MacOS, and my colleague is on Windows, we will be generating different Is there any way to avoid the platform-specific esbuild package from ending up in |
This happened to me because I had |
for when youre switching between a mac and devcontainer
#!/bin/bash
# test for node_modules availability
if [[ -d node_modules ]]; then
# darwin, linux, etc
PLATFORM="$(echo `uname -s` | tr '[:upper:]' '[:lower:]')"
# test for absent esbuild platform install
if [[ "$(npm list --depth=2 | grep -e "─ @esbuild/$PLATFORM" | wc -l | xargs)" -eq 0 ]]; then
# delete node_modules
rm -rf node_modules;
fi
fi
# install when missing
if ! [ -d node_modules ]; then npm install; fi
install:
@if [ -d node_modules ]; then \
PLATFORM="$$(echo `uname -s` | tr '[:upper:]' '[:lower:]')"; \
if [ "$$(npm list --depth=2 | grep -e "─ @esbuild/$$PLATFORM" | wc -l | xargs)" -eq 0 ]; then \
rm -rf node_modules; \
fi; \
fi
if ! [ -d node_modules ]; then npm install; fi edit: support initially absent node_modules |
Solution for me was installing
When running on windows i'm running:
and as you can guess the yarn fails, but because it's in the end it fails when everything is already installed :) a little hack but i guess this bug is in the library. |
Two options that works on gitlab's docker compose (node:20-buster) №1 # Build frontend
- rm -rf node_modules/.cache/
- npm install
- npm i @esbuild/linux-x64 --save-dev
- npm run test:unit
- npm run build №2 # Build frontend
- rm -rf node_modules
- npm install
- npm run test:unit
- npm run build |
Happened to me using yarn. The different arches were listed in the lock file, but they weren't in the yarn cache. adding this to
|
To anyone who wants to fix this, but does not want to remove |
For those which runs this issue on mac with NPM can fix it running |
Also running We have some devs working on Windows and others working on Linux. Reproduction steps are easy:
|
Yarn provides |
I'd recommend using this instead of the ignore platforms flag if you just have two OSs you're worried about. The flag will create unnecessary bloat.
|
Thanks. That did not work for me. I have two OSs, but node_modules is mapped from one OS to another. The guest OS has to use the host OS's node_modules where yarn only gives me the package of one platform instead of multiple platforms. supportedArchitectures has no effect in this case for me |
|
As of 2024 |
I was having the same issue. I am using Remix which uses Vite (vite uses esbuild to transpile typescript to javascript) - while deploying this on Vercel it resulted in this error
|
Also getting this error on Vercel, when trying to use the VueEmail library with Nuxt. I use npm and node 20. Somehow related to vue-email/nuxt#40 Very weird behaviour from esbuild or npm or vercel or nitro or I don't know who's responsible for that but this seems like we have a tough problem here. |
Hi, the need to rely on optional dependencies is problematic in our context, as we have Cypress as an optional dependency and it usually doesn't install properly on CI, in addition to contribution to a long build time. |
If you set If the necessary package wasn't automatically installed because If installing with a nested All of this happens in lib/npm/node-install.ts if you want to see the logic for yourself. You may see logs like this when esbuild does its fallback behaviors:
TL;DR: Your best bet for compatibility is to have optional dependencies enabled (with or without |
Wow thanks for the complete answer! Yeah ok so I'll reconsider my views on "optional". Previously I would tend to consider that "dependencies" is meant for runtime deps, "devDependencies" for build-time deps, and "optionalDependencies" for development tooling, in reaction to the fact the the meaning of each of these field has shifted since when Node.js was designed, because a build step was added to most technologies afterwards. I can't explain why the alternate strategies all failed, using Vercel + a PNPM monorepo, somehow I don't have much logs, I only see some kind of retry strategy but no additional error message. Probably because of pnpm according to your answer. Anyway I could get rid of the --no-opttional. |
I'd like to mention that the "Vercel-like" error is caused by build tools not embedding the required package (here I already made some explanations here but forgot to duplicate it. {
...
"scripts": {
"build": "nuxt build && cp -r ./node_modules/esbuild-linux-64 ./.vercel/output/functions/__nitro.func/node_modules/esbuild-linux-64",
},
...
} This would make sure the required dependency is correctly included in the "built node_modules". |
What fixed for me was to add this package as an optional dependency in the
|
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: vitejs/vite#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:The text was updated successfully, but these errors were encountered: