Skip to content
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

vite build failed due esbuild platform mismatch error #3

Open
andp97 opened this issue Feb 21, 2023 · 1 comment
Open

vite build failed due esbuild platform mismatch error #3

andp97 opened this issue Feb 21, 2023 · 1 comment
Assignees

Comments

@andp97
Copy link
Contributor

andp97 commented Feb 21, 2023

Step to reproduce:

$ git clone <repo>
$ npm run build

> build
> vite build

failed to load config from /Users/user/projects/Linky/vite.config.js
error during build:
Error: 
You installed esbuild for another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.

Specifically the "@esbuild/linux-arm64" package is present but this platform
needs the "@esbuild/darwin-arm64" package instead. People often get into this
situation by installing esbuild on Windows or macOS and copying "node_modules"
into a Docker image that runs Linux, or by copying "node_modules" between
Windows and WSL environments.

If you are installing with npm, you can try not copying the "node_modules"
directory when you copy the files over, and running "npm ci" or "npm install"
on the destination platform after the copy. Or you could consider using yarn
instead of npm which has built-in support for installing a package on multiple
platforms simultaneously.

If you are installing with yarn, you can try listing both this platform and the
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.

Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.
@andp97 andp97 self-assigned this Feb 21, 2023
andp97 added a commit that referenced this issue Feb 21, 2023
Signed-off-by: Andrea Pavone <info@andreapavone.com>
@andp97
Copy link
Contributor Author

andp97 commented Feb 21, 2023

Fix:

rm package-lock.json
npm install

Or

npm update

(but if added to git other can throw the same error)

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

1 participant