Nextjs 14 build issue

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.
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.
2 Replies
NeoFox
NeoFox6mo ago
It seems like its expecting the common js syntax. Its most likely an issue with eslint.
utdev
utdev6mo ago
hmm maybe but I have no idea what to look at or how to fix it I am not using any fancy eslint rules
{
"extends": "next/core-web-vitals"
}
{
"extends": "next/core-web-vitals"
}
issue was that I was usign crypto on the client side it seems, fixed it now !close