Next.js Discord

Discord Forum

Nextjs 14 build error

Answered
Champagne D’Argent posted this in #help-forum
Open in Discord
Champagne D’ArgentOP
I get this weird error running the build command on next 14:

pnpm build

> what_zip@0.1.0 build /Users/utdev/code/what_zip
> next build

   â–² Next.js 14.0.3
   - Environments: .env

Failed to compile.

static/media/thread.2465a67c.js from Terser
  x 'import', and 'export' cannot be used outside of module code
   ,-[1:1]
 1 | import { Buffer } from "node:buffer";
   : ^^^^^^
 2 | import crypto from "node:crypto";
 3 | import { parentPort } from "node:worker_threads";
 4 | parentPort.on("message", (message)=>{
   `----

Caused by:
    0: failed to parse input file
    1: Syntax Error
Error:
  x 'import', and 'export' cannot be used outside of module code
   ,-[1:1]
 1 | import { Buffer } from "node:buffer";
   : ^^^^^^
 2 | import crypto from "node:crypto";
 3 | import { parentPort } from "node:worker_threads";
 4 | parentPort.on("message", (message)=>{
   `----

Caused by:
    0: failed to parse input file
    1: Syntax Error


> Build failed because of webpack errors
   Creating an optimized production build  . ELIFECYCLE  Command failed with exit code 1.
Answered by Champagne D’Argent
Was due to calling crypto on a client componetn
View full answer

1 Reply

Champagne D’ArgentOP
Was due to calling crypto on a client componetn
Answer