vercel: Using esbuild in serverless functions fails due to "esbuild-linux-64" not being found
Discussed in https://github.com/vercel/vercel/discussions/6865
<div type='discussions-op-text'>Originally posted by hassanzadeh October 19, 2021 Hey guys, Starting form about a week ago, all my deployments fail at Run time with this error (copied form functions log): “2021-10-19T17:58:53.710Z f7284007-d328-48a7-b4e3-ecf669500227 ERROR Error: The package “esbuild-linux-64” could not be found, and is needed by esbuild. If you are installing esbuild with npm, make sure that you don’t specify the “–no-optional” flag. The “optionalDependencies” package.json feature is used by esbuild to install the correct binary executable for your current platform. at generateBinPath (/var/task/node_modules/esbuild/lib/main.js:1643:15)”
I’m not sure what has changed under the hood that is causing everything to break. I also noticed that I’m getting these warnings during the build time; Info esbuild-darwin-arm64@0.13.8: The platform “linux” is incompatible with this module.
Any thoughts? thanks </div>
Hello!
It appears that using esbuild in serverless functions doesn’t work, I’ve been getting the same error described in the discussion above, i.e. esbuild cannot find esbuild-linux-64. I created a Remix project from Vercel’s template and ran esbuild in the home page’s loader to demonstrate this issue, it’s deployed at https://silvenon-repro.vercel.app, where you can clearly see the error. The project builds fine, so the esbuild that Remix itself uses under the hood works fine in the build step, but using esbuild separately later, in the application itself, doesn’t work.
Any help with this would be highly appreciated ❤️
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 26 (3 by maintainers)
Commits related to this issue
- [cli][node] Bump nft to 0.17.5 (#7349) - Fixes #7287 — committed to vercel/vercel by styfle 2 years ago
- feat(templates/vercel): enable Build Output API v3 esbuild works correctly on this version of Build Output API, it chooses the correct binary. vercel/vercel#7287 — committed to silvenon/remix by silvenon 2 years ago
- feat(templates/vercel): enable Build Output API v3 esbuild works correctly on this version of Build Output API, it chooses the correct binary. vercel/vercel#7287 — committed to silvenon/remix by silvenon 2 years ago
- try to fix build issue as per https://github.com/vercel/vercel/issues/7287#issuecomment-1140265862 — committed to justin-hackin/svg-widgets-monorepo by justin-hackin a year ago
- add vercel.json ref: https://github.com/vercel/vercel/issues/7287#issuecomment-1140265862 — committed to kimizuy/next-i18n-deepl-portfolio-template by kimizuy 8 months ago
I’m in somewhat the same boat as you, @silvenon. I wanted to try out Remix, so I built a blog that uses mdx-bundler, deployed to vercel, and came across this issue. In my case I am fetching the MDX content from an API instead of reading from the filesystem.
Remix purposely does not support SSG, so mdx-bundler seemed like the best solution, plus it gets a mention in the docs.
@Infi-Knight it turns out that all you need to do is add an environment variable in your
vercel.jsonfile, Remix team doesn’t need to do anything.You can also turn on
ENABLE_FILE_SYSTEM_APIthe same way if you need filesystem access. My example app doesn’t because it’s compiling strings, not files.Check out the working deployment of my app: https://repro-remix-esbuild-vercel-72x4eh7fe-silvenon.vercel.app/
I’ll close this because apparently the problem is solved 🎉
@silvenon fishing for more updates here - it looks like the root cause of the error should be resolved if remix is able to update their deploy adapter to the latest version of the build output api - I have been in contact with their team about this but haven’t got a response yet. Hopefully it’s something that will happen soon!
What do you mean by “API function”? My repro-remix-esbuild-vercel is a somewhat minimal demo of the issue. The error that appears in the app is not the one described in this issue because I didn’t know how to make that messsage appear in the frontend, but the error is visible in the function logs:
Would you mind describing what exactly I would need to do to make this work? I would like to edit the issue description with that info so that the comments in this issue hopefully stop repeating themselves.
Hey @jescalan! My use case is compiling MDX blog posts upon request using mdx-bundler, which uses esbuild.
Considering that Remix compiles to
/api/index.js, is calling esbuild from there different than yourapi/esbuild.jsexample? Also, based on what @styfle said I assumed that compiling strings works now, but not files. But I didn’t try it out.I see now. Remix is using the experimental Filesystem API https://github.com/silvenon/repro/blob/2e26ea8f10ef90e46bb3102bfb90633b273ab84e/vercel.json#L7
We’ll have to update that separately.
We need to land https://github.com/vercel/vercel/pull/7349 for node.
Or if you’re using Next.js you could try next@canary
No 😕