warn - Attempted to load @next/swc-linux-x64-

问题描述:

node项目构建
构建命令:npm run build:test

报错如下:

.........
fo  - 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
panicked at 'The global thread pool has not been initialized.: ThreadPoolBuildError { kind: IOError(Error { kind: Unsupported, message: "operation not supported on this platform" }) }', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.9.1/src/registry.rs:170:10

Stack:

Error
    at module.exports.__wbg_new_693216e109162396 (/data/wwwroot/default/website-promote/node_modules/next/wasm/@next/swc-wasm-nodejs/wasm.js:202:17)
    at <anonymous>:wasm-function[5445]:0xf90917
    at <anonymous>:wasm-function[13700]:0x11eca7b
    at <anonymous>:wasm-function[9995]:0x1186adc
    at <anonymous>:wasm-function[11009]:0x11b6862
    at <anonymous>:wasm-function[12785]:0x11e5cdd
    at <anonymous>:wasm-function[11383]:0x11c358f
    at <anonymous>:wasm-function[10017]:0x1187e72
    at <anonymous>:wasm-function[1151]:0x98decd
    at <anonymous>:wasm-function[654]:0x75f3f2
    ........
原因:

nodejs官网说明:https://nextjs.org/docs/messages/failed-loading-swc

SWC 加载失败:
Next.js 现在使用基于 Rust 的编译器SWC来编译 JavaScript/TypeScript。这个新编译器在编译单个文件时比 Babel 快 17 倍,Fast Refresh 快 5 倍。

SWC 需要下载与您的系统特定兼容的二进制文件。在某些情况下,此二进制文件可能因下载失败或与您的架构不兼容而无法加载。
在这里插入图片描述

解决fang法:

将swcMinify的值改为false,即不使用swc编译器来编译
在这里插入图片描述