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

待继续补充

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

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

在这里插入图片描述

欢迎路过的小哥哥小姐姐们提出更好的意见哇~~

posted @   糖~豆豆  阅读(769)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
历史上的今天:
2021-09-14 Flutter2.X学习之路--调试页面布局好用的办法
Live2D
欢迎阅读『next系列-报错以及解决方案记录』
点击右上角即可分享
微信分享提示