1
resposta

Build failed because of webpack errors

Olá, estou tentando fazer o build com o atalho yarn export mostrado na aula 02.02, porém estou tendo erro na hora de fazer o build. Abaixo meu package.json e o log de erro. Minha versã do node é a 16.16.0 rodando em ambiente linux (Ubuntu 22.04). Alguém já teve esse erro, e poderia me ajudar por favor?

{
  "name": "alura-cases-divulgacao",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "export": "next build && next export",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "next": "12.2.2",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  },
  "devDependencies": {
    "eslint": "8.20.0",
    "eslint-config-next": "12.2.2"
  }
}
yarn run v1.22.19
warning ../../../../../../package.json: No license field
$ next build && next export
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/alexandre/Projetos/Cursos/Alura/Formacoes/NextJS/alura-cases-divulgacao/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-2e315a3383098fda.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
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
1 resposta

Opa Alexandre, tudo certo?

Sinto muito pela demora em obter um retorno.

O erro menciona a ausência de alguns arquivos compartilhados (libssl.so.1.1 e libc.musl-x86_64.so.1) necessários para o funcionamento correto do pacote. Isso pode estar ocorrendo porque algumas dependências não foram instaladas corretamente ou estão faltando no seu ambiente Linux.

Uma possível solução para esse problema é instalar as dependências de desenvolvimento necessárias manualmente. Você pode tentar executar os seguintes comandos no terminal, no diretório do seu projeto:

yarn add @next/swc-linux-x64-gnu
yarn add @next/swc-linux-x64-musl

Ou rodar o comando que atualize todos os pacotes do seu projeto:

yarn upgrade

Esses comandos devem instalar as dependências ausentes.

Se precisar de ajuda ou tiver alguma dúvida, estou à disposição, conte comigo!

Um bom dia e bons estudos

Caso este post tenha lhe ajudado, por favor, marcar como solucionado ✓

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software