Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open next fails to build when used with the pages and app router #380

Open
V01D-NULL opened this issue Mar 11, 2024 · 3 comments
Open

open next fails to build when used with the pages and app router #380

V01D-NULL opened this issue Mar 11, 2024 · 3 comments

Comments

@V01D-NULL
Copy link

Codepipeline logs:

┌──────────────────────────────┐
--
76 | │ OpenNext — Generating bundle │
77 | └──────────────────────────────┘
78 |  
79 | Bundling static assets...
80 | node:fs:2969
81 | handleErrorFromBinding(ctx);
82 | ^
83 |  
84 | Error: ENOENT: no such file or directory, copyfile '/codebuild/output/src53762765/src/next/.next/BUILD_ID' -> '/codebuild/output/src53762765/src/next/.open-next/assets/BUILD_ID'
85 | at Object.copyFileSync (node:fs:2969:3)
86 | at createStaticAssets (file:///root/.npm/_npx/baabbad97c6af5a7/node_modules/open-next/dist/build.js:289:8)
87 | at build (file:///root/.npm/_npx/baabbad97c6af5a7/node_modules/open-next/dist/build.js:30:5) {
88 | errno: -2,
89 | syscall: 'copyfile',
90 | code: 'ENOENT',
91 | path: '/codebuild/output/src53762765/src/next/.next/BUILD_ID',
92 | dest: '/codebuild/output/src53762765/src/next/.open-next/assets/BUILD_ID'
93 | }
94 |  
95 | Node.js v18.18.2
96 | Error: Command failed: npx [email protected] build
97 | at checkExecSyncError (node:child_process:890:11)
98 | at execSync (node:child_process:962:15)
99 | at NextjsBuild.build (/codebuild/output/src53762765/src/cdk/node_modules/cdk-nextjs-standalone/src/NextjsBuild.ts:151:13)
100 | at new NextjsBuild (/codebuild/output/src53762765/src/cdk/node_modules/cdk-nextjs-standalone/src/NextjsBuild.ts:116:14)
101 | at new Nextjs (/codebuild/output/src53762765/src/cdk/node_modules/cdk-nextjs-standalone/src/Nextjs.ts:156:22)
102 | at CoScheduleWebsiteStack.buildNextConstruct (/codebuild/output/src53762765/src/cdk/lib/cdk-stack.ts:32:20)
103 | at new CoScheduleWebsiteStack (/codebuild/output/src53762765/src/cdk/lib/cdk-stack.ts:26:10)
104 | at defineStack (/codebuild/output/src53762765/src/cdk/bin/cdk.ts:27:5) {
105 | status: 1,
106 | signal: null,
107 | output: [ null, null, null ],
108 | pid: 322,
109 | stdout: null,
110 | stderr: null
111 | }
112 |  
113 | Subprocess exited with error 1

I'm in the process of migrating our pages router to the new app router, all I changed was the bare minimum. New useRouter hooks in a global component, adding a layout.tsx, metadata, etc.

After doing that I've seen our builds fail on staging when running npx [email protected] build. Building via next build works fine, so this is breaking somewhere in open-next.

Any ideas?

@khuezy
Copy link
Contributor

khuezy commented Mar 11, 2024

Are you mixing cdk-nextjs-standalone with open-next? The output src folder looks sus: src53762765

@V01D-NULL
Copy link
Author

V01D-NULL commented Mar 12, 2024

Yes, actually.
version ^4.0.0-beta.28

We use cdk-nextjs-standalone in our code and invoke open next in the buildCommand npx [email protected] build

@V01D-NULL
Copy link
Author

so quick update... buildCommand: 'npm run build && npx [email protected] build' seems to work as a temporary fix
Where the build script is just next build

Previously buildCommand was just npx [email protected] build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants