next.js: Error loading shared library ld-linux-x86-64.so.2 on Alpine

What version of Next.js are you using?

12.0.2

What version of Node.js are you using?

16.x

What browser are you using?

none

What operating system are you using?

alpine

How are you deploying your application?

next build

Describe the Bug

next 12.0.2 app is failing to build on Alpine linux with following error. It was first appeared in 12.0.0, then fixed in 12.0.1. Now it’s back in 12.0.2.

Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by ....)

Expected Behavior

next build should work

To Reproduce

create next app using 12.0.2, then try to build on Alpine linux.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 20
  • Comments: 44 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for confirming @mtsewrs, we’ll get it out on stable soon (today/tomorrow) 👍 Going to close this issue as we close issues when the fix has landed 👍

Can this be re-opened?

#14 3.162 Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/src/app/node_modules/@next/swc-linux-x64-gnu/next-swc.linux-x64-gnu.node)
#14 3.162     at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
#14 3.162     at Module.load (internal/modules/cjs/loader.js:950:32)
#14 3.162     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
#14 3.162     at Module.require (internal/modules/cjs/loader.js:974:19)
#14 3.162     at require (internal/modules/cjs/helpers.js:93:18)
#14 3.162     at Object.<anonymous> (/usr/src/app/node_modules/next/dist/build/swc/index.js:29:20)
#14 3.162     at Module._compile (internal/modules/cjs/loader.js:1085:14)
#14 3.162     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
#14 3.162     at Module.load (internal/modules/cjs/loader.js:950:32)
#14 3.162     at Function.Module._load (internal/modules/cjs/loader.js:790:12) {
#14 3.162   code: 'ERR_DLOPEN_FAILED'

on 12.0.2 Docker image: node:14.18.1-alpine

This is still occurring in v12.0.4 for node-14 docker image.

@degitgitagitya You can remove node_modules/@next/swc-linux-x64-gnu as a workaround.

This issue is still occurring for me … I tried all suggestions in convos above and some mixtures of them, etc

This is now fixed on next@canary, please give it a try!

Verified based on the Dockerfile shared in this comment: https://github.com/vercel/next.js/issues/30713#issuecomment-959134683

This issue needs to be reopened, vercel pipeline still crashes when building next on 12.0.7.

@timneutkens I am still getting this error on Next@12.0.3 deploying on Vercel, after a clean install on macOS

18:53:55.417 | error - Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc
-- | --
18:53:55.445 | Error: Command "npm run build" exited with 1

EDIT

After another clean install && push it works

@kdy1 So I’m using a docker container to build node:16-alpine so it seems to be an issue with alpine, works perfect locally on linux