Giter VIP home page Giter VIP logo

Comments (6)

evanw avatar evanw commented on May 26, 2024

Please read the “getting started” instructions: https://esbuild.github.io/getting-started/#simultaneous-platforms

from esbuild.

andre-beeclever avatar andre-beeclever commented on May 26, 2024

Yeah but the install process on M1 still adds a arm specific package to the package.json which will cause an error on x64.

from esbuild.

evanw avatar evanw commented on May 26, 2024

You cannot install esbuild on one OS, copy the node_modules directory to another OS without reinstalling, and then run esbuild on that other OS. This won't work because esbuild is written with native code and needs to install a platform-specific binary executable. Normally this isn't an issue because you typically check your package.json file into version control, not your node_modules directory, and then everyone runs npm install on their local machine after cloning the repository.

However, people sometimes get into this situation by installing esbuild on Windows or macOS and copying their node_modules directory into a Docker image that runs Linux, or by copying their node_modules directory between Windows and WSL environments. The way to get this to work depends on your package manager:

  • npm/pnpm: If you are installing with npm or pnpm, 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 which has built-in support for installing a package on multiple platforms simultaneously.

  • Yarn: 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. Keep in mind that this means multiple copies of esbuild will be present on the file system.

You can also get into this situation on a macOS computer with an ARM processor if you install esbuild using the ARM version of npm but then try to run esbuild with the x86-64 version of node running inside of Rosetta. In that case, an easy fix is to run your code using the ARM version of node instead, which can be downloaded here: https://nodejs.org/en/download/.

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.

from esbuild.

andre-beeclever avatar andre-beeclever commented on May 26, 2024

Yeah sure, we are not copying the the node modules. We use git, and the node modules are ignored. But as soon as one ran npm i on an arm mac, the esbuild-darwin-arm64 package appears in the dev dependencies of the package json. This can't be intended, as it causes an error when trying to install the project on another platform. Shouldn't esbuild be added to to the dev dependencies, so it can install the right binary on each system? There should not be platform specific modules in the package.json.

Sorry for bothering you with this.

from esbuild.

hyrious avatar hyrious commented on May 26, 2024

Shouldn't esbuild be added to to the dev dependencies,

Yes it should be esbuild in devDependencies. Maybe there's some custom install script that adds platform specific esbuild variant to your package.json. You need to debug that for yourself.

from esbuild.

andre-beeclever avatar andre-beeclever commented on May 26, 2024

Ok thanks.

from esbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.