next系列-报错以及解决方案记录

1. Failed to load SWC binary for linux/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc

今天部署项目遇到下面报错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.

解决方案1:

  1. 如果你使用的是docker 部署方案,添加下面的命令到你的Dockerfile
RUN npm install -D @swc/cli @swc/core

解决方案2:

下面这段话是从stackoverflow找到的:
https://stackoverflow.com/questions/69816589/next-failed-to-load-swc-binary/70360521

1. next.json.js添加
{
swcMinify: false // it should be false by default 
}
2. 新增这个文件.babelrc到项目根路径,并写入

{
"presets": ["next/babel"]
}
3. 运行这个命令,因为步骤1-2将删除 SWC 加载失败错误,但是当您运行构建命令时,您将注意到另一个错误。所以把这个也运行一下
npm install next@canary

待继续补充

  • 今天就写到这里啦~
  • 小伙伴们,( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝ我们明天再见啦~~
  • 大家要天天开心哦

欢迎大家指出文章需要改正之处~
学无止境,合作共赢

在这里插入图片描述

欢迎路过的小哥哥小姐姐们提出更好的意见哇~~
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值