1. Failed to load SWC binary for linux/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc
Today I encountered the following error when deploying the project: Attempted to load @next/swc-linux-x64-gnu, but it was not installed Attempted to load @next/swc-linux-x64-gnux32, but it was not installed Attempted to load @next /swc-linux-x64-musl, but it was not installed Failed to load SWC binary for linux/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc
[dev:*client] warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
[dev:*client]
[dev:*client] > [PWA] PWA support is disabled
[dev:*client] info - Attempted to load @next/swc-linux-x64-gnu, but it was not installed
[dev:*client] info - Attempted to load @next/swc-linux-x64-gnux32, but it was not installed
[dev:*client] info - Attempted to load @next/swc-linux-x64-musl, but it was not installed
[dev:*client] error - Failed to load SWC binary for linux/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc
[dev:*client] ELIFECYCLE Command failed with exit code 1.
[dev:*client] ELIFECYCLE Command failed with exit code 1.
[dev:*client] pnpm run dev:client exited with code 1
[dev:*server] [11:42:43 AM] Found 0 errors. Watching for file changes.
Solution 1:
- If you are using docker deployment solution, add the following command to your Dockerfile
RUN npm install -D @swc/cli @swc/core
Solution 2:
The following passage was found from stackoverflow:
https://stackoverflow.com/questions/69816589/next-failed-to-load-swc-binary/70360521
1. next.json.js added
{
swcMinify: false // it should be false by default
}
2. Add this file .babelrc to the project root path and write
{
"presets": ["next/babel"]
}
3. Run this command as steps 1-2 will remove the SWC load failed error, but when you run the build command you will notice another error. So run this as well
npm install next@canary
To be further added
- That’s all for today~
- Friends, ( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝSee you tomorrow~~
- Everyone, please be happy every day
Everyone is welcome to point out what needs to be corrected in the article ~
there is no end to learning and win-win cooperation