Closed PBnJson closed 2 weeks ago
also happens to me but only when building docker image, which is weird. i've tried alpine, debian and even archlinux as base images, same error
my nextjs.config.js has nothing but rewrites in it
using next 14.2.5
honestly I have no idea what the exact issue is. seems to be related to zod and/or openai-node
project repo: https://github.com/eyenalxai/paste
steps to reproduce:
git clone https://github.com/eyenalxai/paste.git && cd paste
docker build --build-arg NEXT_PUBLIC_FRONTEND_URL=https://whatever.com -t paste:latest .
i will try to pinpoint the issue in the meantime
Can't be zod
or openai-node
or alteast not directly
I've the same happen for this packages set:
"dependencies": {
"@mdx-js/loader": "3.0.1",
"@mdx-js/react": "3.0.1",
"@next/mdx": "14.2.6",
"class-variance-authority": "0.7.0",
"codehike": "1.0.0-beta.9",
"gray-matter": "4.0.3",
"lucide-react": "0.435.0",
"next": "14.2.5",
"next-mdx-remote": "5.0.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"remark-gfm": "4.0.0"
},
"devDependencies": {
"@types/mdx": "2.0.13",
"@types/node": "22.5.0",
"@types/react": "18.3.4",
"@types/react-dom": "18.3.0",
"eslint": "8.57.0",
"eslint-config-next": "14.2.6",
"postcss": "8.4.41",
"tailwindcss": "3.4.10",
"typescript": "5.5.4"
}
Since you ain't using .mdx
, those can be ruled out, and not much is left what could be a culprit
The same thing happened to me on when building Next.js on docker in Github Actions for Cypress E2E tests.
https://github.com/cypress-io/github-action?tab=readme-ov-file#docker-image
▲ Next.js 14.2.5
Creating an optimized production build ... Failed to compile.
static/chunks/516-dd8f1e03298072f7.js from Terser invalid unicode code point at line 1 column 76631 Error: invalid unicode code point at line 1 column 76631
The same thing happened when I built Nextjs on the @DigitalOcean app platform.
static/chunks/f52d054b-e146e205a9860f66.js from Terser [2024-08-25 09:17:19] │ invalid unicode code point at line 1 column 995672
I think I've found a consistent way to trigger the error.
One of these lines triggers the error, other does not: https://github.com/eyenalxai/paste/blob/97e9821d709ff25e1ea7686a72aed9970a84a8af/lib/syntax/detect.ts#L34
To reproduce:
git clone https://github.com/eyenalxai/paste.git -b terser-error && cd paste
docker build -t paste:latest .
This will result in an error.
Then, swap the comments on the lines as follows:
// const what = ooofs // Terser error
const what = "what" // No error
Run docker build -t paste:latest .
again, should build successfully.
I had the same issue. Seems like that the latest node version does not work with terser and will throw this wreid error.
I used node-version: "20.10.0" which works for me.
FWIW, I had no issues with my builds using Node version 20.17.0 up until 2 days ago, on August 23rd.
Prior to that, deployments would succeed without this invalid unicode code point
error.
So, it seems to be a very new issue with how strings are being parsed by Terser.
I tried downgrading to Node version 20.10.0 as suggested by @C3ntraX, but still no luck
also happens to me but only when building docker image, which is weird. i've tried alpine, debian and even archlinux as base images, same error
my nextjs.config.js has nothing but rewrites in it
using next 14.2.5
I can confirm that the issue only happens when building my Next.js v14.2.6 app as a Docker image. I do not experience the error at all when I build my Next.js app locally; the build always fails in my GitHub Actions CI/CD script.
I was able to isolate the file which causes the issue; however, I haven't made any significant changes since before this issue arose.
That change is 3 lines which makes no use of string manipulation, only array filtering and the use of .includes
on a string.
I would share the file, but I think it is unnecessary, given my previous sentence.
Catching the same problem - Nextjs 13.2.4 / Docker / Github actions / Nodejs slim 16
#8 20.95 info - Creating an optimized production build...
#8 68.91 Failed to compile.
#8 68.91
#8 68.91 static/chunks/2617-257e92d53d9ab516.js from Terser
#8 68.91 invalid unicode code point at line 1 column 114079
#8 68.91 Error: invalid unicode code point at line 1 column 114079
#8 68.91 at Object.minify (/app/node_modules/next/dist/build/swc/index.js:363:33)
#8 68.91 at Object.minify (/app/node_modules/next/dist/build/swc/index.js:465:21)
#8 68.91 at async Object.minify (/app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:146:44)
#8 68.91 at async /app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:202:42
#8 68.91 at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:79:20)
Tried versions 20.14.0 and 20.10.0 - did not solve the problem.
As a temporary solution I disabled swc in next.config.js.
Happening to me as well! Even locally on my mac..
> next build
▲ Next.js 14.2.6
- Environments: .env
- Experiments (use with caution):
· turbo
· instrumentationHook
Creating an optimized production build ...
(node:7717) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Failed to compile.
../app/api/(resources)/customers/[id]/route.js from Terser
invalid unicode code point at line 1 column 53354
Error: invalid unicode code point at line 1 column 53354
at Object.minify (/Users/x/CodeProjects/x/node_modules/.pnpm/next@14.2.6_@babel+core@7.25.2_@opentelemetry+api@1.9.0_@playwright+test@1.46.1_react-dom@18._xv2sk2z3ei2wm2p6w5ktn72f5y/node_modules/next/dist/build/swc/index.js:814:33)
at Object.minify (/Users/x/CodeProjects/x/node_modules/.pnpm/next@14.2.6_@babel+core@7.25.2_@opentelemetry+api@1.9.0_@playwright+test@1.46.1_react-dom@18._xv2sk2z3ei2wm2p6w5ktn72f5y/node_modules/next/dist/build/swc/index.js:891:21)
at async Object.minify (/Users/x/CodeProjects/x/node_modules/.pnpm/next@14.2.6_@babel+core@7.25.2_@opentelemetry+api@1.9.0_@playwright+test@1.46.1_react-dom@18._xv2sk2z3ei2wm2p6w5ktn72f5y/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:149:44)
at async /Users/x/CodeProjects/x/node_modules/.pnpm/next@14.2.6_@babel+core@7.25.2_@opentelemetry+api@1.9.0_@playwright+test@1.46.1_react-dom@18._xv2sk2z3ei2wm2p6w5ktn72f5y/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:205:42
at async Span.traceAsyncFn (/Users/x/CodeProjects/x/node_modules/.pnpm/next@14.2.6_@babel+core@7.25.2_@opentelemetry+api@1.9.0_@playwright+test@1.46.1_react-dom@18._xv2sk2z3ei2wm2p6w5ktn72f5y/node_modules/next/dist/trace/trace.js:154:20)```
../app/api/(resources)/customers/[id]/route.js from Terser
My Next.js build using GitHub Actions fails on an API route as well.
../app/api/(resources)/customers/[id]/route.js from Terser
My Next.js build using GitHub Actions fails on an API route as well.
Downgrading node from 22-alpine
to 20-alpine
helped, I guess any older version would work fine. I re-ran CI/CD old pipelines which succeeded at first, but they now seem to fail as well.
Here's what my build logs from GitHub Actions look like:
#11 [6/6] RUN npx turbo build
#11 0.660
#11 0.660 Attention:
#11 0.660 Turborepo now collects completely anonymous telemetry regarding usage.
#11 0.660 This information is used to shape the Turborepo roadmap and prioritize features.
#11 0.660 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
#11 0.660 https://turbo.build/repo/docs/telemetry
#11 0.660
#11 0.662 turbo 2.0.14
#11 0.662
#11 0.666 • Running build
#11 0.666 • Remote caching disabled
#11 0.700 build: cache miss, executing 4bd64f6669a19717
#11 0.847 build:
#11 0.849 build: > personality-lab@1.0.0 build
#11 0.849 build: > next build
#11 0.850 build:
#11 1.647 build: Attention: Next.js now collects completely anonymous telemetry regarding usage.
#11 1.649 build: This information is used to shape Next.js' roadmap and prioritize features.
#11 1.649 build: You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
#11 1.649 build: https://nextjs.org/telemetry
#11 1.649 build:
#11 1.727 build: ▲ Next.js 14.2.6
#11 1.727 build: - Environments: .env.local
#11 1.728 build:
#11 1.826 build: Creating an optimized production build ...
#11 32.52 build: Failed to compile.
#11 32.52 build:
#11 32.52 build: ../app/api/study/participant/route.js from Terser
#11 32.52 build: invalid unicode code point at line 1 column 41728
#11 32.52 build: Error: invalid unicode code point at line 1 column 41728
#11 32.52 build: at Object.minify (/personality-lab-app/node_modules/next/dist/build/swc/index.js:814:33)
#11 32.52 build: at Object.minify (/personality-lab-app/node_modules/next/dist/build/swc/index.js:891:21)
#11 32.52 build: at async Object.minify (/personality-lab-app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:149:44)
#11 32.52 build: at async /personality-lab-app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:205:42
#11 32.52 build: at async Span.traceAsyncFn (/personality-lab-app/node_modules/next/dist/trace/trace.js:154:20)
#11 32.52 build:
#11 32.54 build:
#11 32.54 build: > Build failed because of webpack errors
#11 32.56 build: ERROR: command finished with error: command (/personality-lab-app/) /usr/local/bin/npm run build exited (1)
#11 32.56 build: command (/personality-lab-app/) /usr/local/bin/npm run build exited (1)
Note that this build succeeded on the latest version of Next.js and Node.js prior to August 23rd.
It builds successfully in local, but fails in ci/cd process like github actions.
Catching the same problem - Nextjs 13.2.4 / Docker / Github actions / Nodejs slim 16
#8 20.95 info - Creating an optimized production build... #8 68.91 Failed to compile. #8 68.91 #8 68.91 static/chunks/2617-257e92d53d9ab516.js from Terser #8 68.91 invalid unicode code point at line 1 column 114079 #8 68.91 Error: invalid unicode code point at line 1 column 114079 #8 68.91 at Object.minify (/app/node_modules/next/dist/build/swc/index.js:363:33) #8 68.91 at Object.minify (/app/node_modules/next/dist/build/swc/index.js:465:21) #8 68.91 at async Object.minify (/app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:146:44) #8 68.91 at async /app/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:202:42 #8 68.91 at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:79:20)
Tried versions 20.14.0 and 20.10.0 - did not solve the problem.
As a temporary solution I disabled swc in next.config.js.
I solved this issue temporarily thanks to comment I replied. However, the swcMinify
option in next.config.mjs
will be enabled by default and removed in Next.js 15. This issue must be resolved before Next.js 15 is released.
Tried versions 20.14.0 and 20.10.0 - did not solve the problem. As a temporary solution I disabled swc in next.config.js.
I solved this issue temporarily thanks to comment I replied. However, the
swcMinify
option innext.config.mjs
will be enabled by default and removed in Next.js 15. This issue must be resolved before Next.js 15 is released.
Yeah, setting:
const nextConfig = {
swcMinify: false
}
does work, but Next.js is removing the ability to disable the SWC Minifier in the next major release, Next.js 15.
So, that workaround will only last until then and therefore isn't ideal.
but Next.js is removing the ability to disable the SWC Minifier in the next major release, Next.js 15.
Yeah, I understand, but Sunday night is not the time for me to deal with this 😅
This is caused by Node.js 22.7.0, downgrading to Node.js 22.6.0 fixes this error. See #69150
Same here deploying in @digitalocean, the solution was to downgrade the node version. So from package.json:
"engines":{
"node": "20.16.0" // Should be < 22.6
},
Had this problem with node:alpine
Docker image. Rolling back to node:lts-alpine
fixed it.
Had this problem with
node:alpine
Docker image. Rolling back tonode:lts-alpine
fixed it.
node:lts-alpine
is a good choice if you’re sticking with alpine
to avoid using the latest version of Node.
I choice to revisit the use of alpine
and found the recommendation given by Snyk in this article to be quite helpful.
https://snyk.io/blog/choosing-the-best-node-js-docker-image/
Maybe it will help some of you to choose the most appropriate Node Docker image too.
The authors of the article suggested using node:lts-bookworm-slim
for security and performance reasons
Solution for me was switching from 'node:bullseye' -> 'node:22.6-bullseye' in the docker image.
node:bullseye started using 22.7.0 when it was available I guess and that made our pipeline explode
Had this problem with
node:alpine
Docker image. Rolling back tonode:lts-alpine
fixed it.
Changing the docker image to node:lts-alpine
solved the issue for now, but it can't be the definitive solution for this problem. I'm going to be watching the thread here to find a solution where working with the latest stable version of Node won't be a problem.
Switching docker image from node:slim
to node:20.13.1-bookworm-slim
resolved the issue for me.
Link to the code that reproduces this issue
https://github.com/PBnJson/reproduction-template
To Reproduce
Current vs. Expected behavior
I expected the project to build and be minified but instead I had to disable minification with swcMinify:false in order to build successfully.
Provide environment information
Which area(s) are affected? (Select all that apply)
Runtime, Script (next/script)
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
I'm deploying in Google Cloud vm instance with Debian. The app was working great before I added the service workers. The error happens at
invalid unicode code point at line 1 column 43757
when I rundocker compose up --build
. DisablingswcMinify
in next.config.js got the build to succeed, so some sort of minification issue.reproduction-template