2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Next.jsでnpm run buildできないときはnext.config.jsの swcMinifyをfalseにするとnpm run buildできるかもしれない。

Posted at

環境
・Ubuntu 22.04 LTS(WSL2)
・Node v16.16.0
・npm 8.11.0
・Next.js 12.2.2
・React 18.2.0

npm run buildを実行すると下記エラーが発生した。

エラーログ
sddd3@wsl:~/dev/abcd$ npm run build

> abcd@0.1.0 build
> next build

info  - SWC minify release candidate enabled. https://nextjs.link/swcmin
info  - Linting and checking validity of types
info  - 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 (/home/sddd3/dev/abcd/node_modules/next/wasm/@next/swc-wasm-nodejs/wasm.js:202:17)
    at wasm://wasm/059aa236:wasm-function[5445]:0xf90917
    at wasm://wasm/059aa236:wasm-function[13700]:0x11eca7b
    at wasm://wasm/059aa236:wasm-function[9995]:0x1186adc
    at wasm://wasm/059aa236:wasm-function[11009]:0x11b6862
    at wasm://wasm/059aa236:wasm-function[12785]:0x11e5cdd
    at wasm://wasm/059aa236:wasm-function[11383]:0x11c358f
    at wasm://wasm/059aa236:wasm-function[10017]:0x1187e72
    at wasm://wasm/059aa236:wasm-function[1151]:0x98decd
    at wasm://wasm/059aa236:wasm-function[654]:0x75f3f2


info  - Creating an optimized production build
Failed to compile.

static/chunks/framework-aceae1aece8045c6.js from Terser
unreachable
RuntimeError: unreachable
    at wasm://wasm/059aa236:wasm-function[9995]:0x1186aff
    at wasm://wasm/059aa236:wasm-function[11009]:0x11b6862
    at wasm://wasm/059aa236:wasm-function[12785]:0x11e5cdd
    at wasm://wasm/059aa236:wasm-function[11383]:0x11c358f
    at wasm://wasm/059aa236:wasm-function[10017]:0x1187e72
    at wasm://wasm/059aa236:wasm-function[1151]:0x98decd
    at wasm://wasm/059aa236:wasm-function[654]:0x75f3f2
    at wasm://wasm/059aa236:wasm-function[654]:0x760098
    at wasm://wasm/059aa236:wasm-function[3154]:0xd6fe73
    at wasm://wasm/059aa236:wasm-function[654]:0x75f24f


> Build failed because of webpack errors

Build failed because of webpack errorsを頼りに解決策を探したところ、webpack5を使うようにする方法があったが解決できなかった。
しかし、swcMinifyをfalseにしたらnpm run buildできた。

next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true, <------ここをfalseにする
}

module.exports = nextConfig

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?