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 @ 2023-09-14 01:32  糖~豆豆  阅读(705)  评论(0编辑  收藏  举报
Live2D