Rails 7 and ESbuild

Im trying to deploy a Rails 7 application.

Im facing issue with ESBuild during yarn install step

Oct. 24 05:43:03 PM  error esbuild-darwin-arm64@0.15.12: The platform "linux" is incompatible with this module.
Oct. 24 05:43:03 PM  error esbuild-darwin-arm64@0.15.12: The CPU architecture "x64" is incompatible with this module.
Oct. 24 05:43:03 PM  error Found incompatible module.
Oct. 24 05:43:03 PM  info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Oct. 24 05:43:03 PM  rake aborted!
Oct. 24 05:43:03 PM  jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors
Oct. 24 05:43:03 PM  /opt/render/project/.gems/ruby/3.0.0/gems/jsbundling-rails-1.0.3/lib/tasks/jsbundling/build.rake:5:in `block (2 levels) in <main>'

I use MacOS for development thus esbuild-darwin-arm64 is in the package.json file. I guess render is expecting esbuild-linux-64. How can I fix this issue?

For reference: Error: The package "esbuild-linux-64" could not be found, and is needed by esbuild · Issue #1646 · evanw/esbuild · GitHub

Certainly, to fix differences between platforms for bundler you need to perform

bundle lock --add-platform x86_64-linux

I checked in my own Rails7 app which uses esbuild and there’s nothing platform specific in my package.json but I can see other platforms in my yarn.lock - and I’m also using an M1 Mac here,

Regards,

John B

Thank you for the reply.

But my issue is with yarn, not bundle. Im not able to find similar command for yarn.

Sharing my package.json


{
  "name": "app",
  "private": "true",
  "dependencies": {
    "@hotwired/stimulus": "^3.0.1",
    "@hotwired/turbo-rails": "^7.1.3",
    "autoprefixer": "^10.4.7",
    "esbuild": "^0.14.48",
    "esbuild-darwin-arm64": "^0.15.12",
    "postcss": "^8.4.14",
    "tailwindcss": "^3.1.4"
  },
  "scripts": {
    "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds",
    "build:css": "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify"
  }
}

Ah, re-reading the error based on your snipper of package.json there, I suspect the issue here is that you explicitly have the darwin-arm64 module in your package.json which will indeed work locally but not on us (or any Linux x86 platform).

My own package.json for a Rail7 app I deploy to us is;

  "scripts": { "build:css": "tailwindcss --postcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css", "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds" }, "dependencies": { "@hotwired/stimulus": "^3.0.1", "@hotwired/turbo-rails": "^7.1.0", "@rails/actioncable": "^7.0.0", "@rails/activestorage": "^7.0.0", "@rails/ujs": "^7.0.0", "debounce": "^1.2.1", "esbuild": "^0.14.2", "postcss-import": "^14.0.2", "postcss-resolve-urls": "^0.0.3", "turbolinks": "^5.2.0" }, "version": "0.1.0

and as I said, I’m using an M1 Macbook pro as well., maybe try removing

 "esbuild-darwin-arm64": "^0.15.12",

John B

Thank you. removing “esbuild-darwin-arm64” helped.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.