next.js: Failed to load SWC binary for linux/x64

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System: Platform: linux Arch: x64 Version: #1 SMP Fri Dec 18 16:34:56 UTC 2020 Binaries: Node: 16.15.1 npm: 8.11.0 Yarn: N/A pnpm: 7.4.0 Relevant packages: next: 12.2.1 eslint-config-next: 12.2.0 react: 17.0.2 react-dom: 16.14.0

What browser are you using? (if relevant)

Chrome 102

How are you deploying your application? (if relevant)

next start

Describe the Bug

my project in gitlab-ci(image: node:lts-buster) buid my app. run next build
i get this error ↓

info  - Skipping linting
info  - Creating an optimized production build...
info  - Downloading WASM swc package...
info  - Using experimental wasm build of next-swc
warn  - Attempted to load @next/swc-linux-x64-gnu, but it was not installed
warn  - Attempted to load @next/swc-linux-x64-gnux32, but it was not installed
warn  - Attempted to load @next/swc-linux-x64-musl, but an error occurred: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory
Failed to compile.```

how can i fix it

### Expected Behavior

null

### Link to reproduction

null

### To Reproduce

null

About this issue

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

Commits related to this issue

Most upvoted comments

Downgrade to 12.2.0 works fine.

I had the same problem too, but I was able to take a temporary solution. The version of OpenSSL installed on AmazonLinux 2 is 1.0.2, so I was able to solve the problem by installing OpenSSL 1.1.1. I thought it would work by installing OpenSSL 1.1.1 in the same way in all Linux environments where OpenSSL 1.0.x is installed.

Example of installing OpenSSL 1.1.1 on AmazonLinux 2.

yum remove openssl-devel -y
yum install openssl11 openssl11-devel -y

I fixed the bug, and by then I forgot to reply to this issue. and the reason I had this problem was because, my gitlab image was chosen incorrectly, I chose the node:lts-alpine docker image in the pnpm install stage, but I chose node:lts-buster in the build stage and run next build, and when I unified the mirroring docker image to node:lts-alpine of the two stages, I fixed the problem.

I’m seeing something similar to this on 12.2.1 using a self-hosted actions runner:

info  - Downloading WASM swc package...
npm WARN config This command does not support workspaces.
warn  - Attempted to load @next/swc-linux-x64-gnu, but an error occurred: libssl.so.1.1: cannot open shared object file: No such file or directory
warn  - Attempted to load @next/swc-linux-x64-gnux32, but it was not installed
warn  - Attempted to load @next/swc-linux-x64-musl, but an error occurred: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory
warn  - Error: request failed with status 401
    at /app/node_modules/next/dist/lib/download-wasm-swc.js:124:23
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.downloadWasmSwc (/app/node_modules/next/dist/lib/download-wasm-swc.js:122:9)
    at async /app/node_modules/next/dist/build/swc/index.js:115:13
error - Failed to load SWC binary for linux/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc
ERROR: command finished with error: command (apps/laww) yarn run build exited (1)

I’m seeing this issue even though I followed this document:

If SWC continues to fail to load you can opt-out by disabling swcMinify in your next.config.js or by adding a .babelrc to your project with the following content:

I’m also seeing this when trying to run next build on an EC2 server:

info  - Using experimental wasm build of next-swc
warn  - Attempted to load @next/swc-linux-x64-gnu, but an error occurred: libssl.so.1.1: cannot open shared object file: No such file or directory
warn  - Attempted to load @next/swc-linux-x64-gnux32, but it was not installed
warn  - Attempted to load @next/swc-linux-x64-musl, but an error occurred: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory
info  - Creating an optimized production build ...

The build seems to be stalling indefinitely.