build시 dynamic route 에러
> duckblog@0.1.0 build
> next build && next export
⚠ Invalid next.config.js options detected:
⚠ Unrecognized key(s) in object: 'appDir' at "experimental"
⚠ Unrecognized key(s) in object: 'dynamic'
⚠ See more info here: https://nextjs.org/docs/messages/invalid-next-config
▲ Next.js 14.0.4
✓ Creating an optimized production build
✓ Compiled successfully
✓ Linting and checking validity of types
> Build error occurred
Error: Page "/post/[id]" is missing "generateStaticParams()" so it cannot be used with "output: export" config.
at /Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/next/dist/build/index.js:1012:59
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Span.traceAsyncFn (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/next/dist/trace/trace.js:147:20)
at async Promise.all (index 6)
at async /Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/next/dist/build/index.js:892:17
at async Span.traceAsyncFn (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/next/dist/trace/trace.js:147:20)
at async /Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/next/dist/build/index.js:829:124
at async Span.traceAsyncFn (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/next/dist/trace/trace.js:147:20)
at async build (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/next/dist/build/index.js:187:29)
at async main (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/next/dist/bin/next:157:5)
next.config.js
/** @type {{output: string, assetPrefix: string, experimental: {appDir: boolean}}} */
const nextConfig = {
experimental: {
appDir: true,
},
output: "export",
assetPrefix: "/duckblog/",
// dynamic: "force-static",
};
module.exports = nextConfig;
build시에 발생하는 에러입니다. dynamic route에서 에러가 발생하는것 같은데 깃헙이슈나 레디스에 올라와있는 방법으로도 잘 해결이 안되네요... output export 를 없애고 빌드르 하면 아래와 같은 에러가 발생합니다

The "next export" command has been removed in favor of "output: export" in next.config.js. Learn more: https://nextjs.org/docs/advanced-features/static-html-export
답변 1
0
next export를 사용하시는 이유가 무엇인가요? 정적 빌드를 하시려는 건가요? /post/[id]같은 dynamic route가 있으면 export할 수 없습니다.
dynamic route를 export하려면 generateStaticParams를 쓰셔야 합니다.
https://nextjs.org/docs/app/api-reference/functions/generate-static-params
0
○ (Static) prerendered as static content
λ (Dynamic) server-rendered on demand using Node.js
Error: ENOENT: no such file or directory, stat '/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/out'
at Object.statSync (node:fs:1690:3)
at Object.statSync (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/graceful-fs/polyfills.js:319:16)
at Object.publish (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/gh-pages/lib/index.js:90:13)
at /Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/gh-pages/bin/gh-pages.js:12:13
at new Promise (<anonymous>)
at publish (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/gh-pages/bin/gh-pages.js:10:10)
at /Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/gh-pages/bin/gh-pages.js:140:12
✘ Duck 🦋 ~/Documents/01.GitHub/duckblog main ± npm run deploy
> duckblog@0.1.0 deploy
> npm run build && gh-pages -d duckblog
> duckblog@0.1.0 build
> next build
⚠ Invalid next.config.js options detected:
⚠ Unrecognized key(s) in object: 'appDir' at "experimental"
⚠ See more info here: https://nextjs.org/docs/messages/invalid-next-config
▲ Next.js 14.0.4
✓ Creating an optimized production build
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
Generating static pages (3/5) [= ]
[
{ title: '[Windows] 시놀로지 외부 네트워크 드라이브 설정 (WebDAV)' },
{ title: '[Windows] 시놀로지 외부 네트워크 드라이브 설정 (WebDAV)' }
]
[
{ title: '[Windows] 시놀로지 외부 네트워크 드라이브 설정 (WebDAV)' },
{ title: '[Windows] 시놀로지 외부 네트워크 드라이브 설정 (WebDAV)' }
✓ Generating static pages (5/5)
✓ Collecting build traces
✓ Finalizing page optimization
Route (app) Size First Load JS
┌ ○ / 823 B 82.7 kB
├ ○ /_not-found 875 B 82.8 kB
└ λ /post/[id] 137 B 82 kB
+ First Load JS shared by all 81.9 kB
├ chunks/938-ae3b98e17d2c2d59.js 26.7 kB
├ chunks/fd9d1056-e2c7d479a52b4888.js 53.3 kB
├ chunks/main-app-6d94b1a10065a558.js 222 B
└ chunks/webpack-8ef64c27aab8ba52.js 1.72 kB
○ (Static) prerendered as static content
λ (Dynamic) server-rendered on demand using Node.js
Error: ENOENT: no such file or directory, stat '/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/duckblog'
at Object.statSync (node:fs:1690:3)
at Object.statSync (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/graceful-fs/polyfills.js:319:16)
at Object.publish (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/gh-pages/lib/index.js:90:13)
at /Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/gh-pages/bin/gh-pages.js:12:13
at new Promise (<anonymous>)
at publish (/Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/gh-pages/bin/gh-pages.js:10:10)
at /Users/gyeongdeokpark/Documents/01.GitHub/duckblog/node_modules/gh-pages/bin/gh-pages.js:140:12
gh-pages를 사용할때 정적 파일을 저장해둔 곳을deploy해줘야 하는것 같은데 deploy 해서 확인해보면 404에러가 뜨고 있습니다.
1
일단 깃헙페이지는 정적이므로 next build 시 output: export를 쓰시는 게 맞고, generateStaticParams로 post/[id]를 전부 미리 빌드하셔야 합니다. 그리고 빌드된 결과물 페이지를 gh-pages로 올리시면 됩니다.
캡처링부분 질문있습니다.
0
76
2
깃에 소스코드를 찾을 수 없습니다.
0
113
2
useInfiniteQuery promise와 react use 사용시 페이지 무한 로딩
0
98
1
import 파일 경로를 찾지 못 해서 에러가 발생합니다.
0
111
2
css 라이브러리 추천 부탁드립니다
0
141
2
팔로우 추천 목록이 빈 배열로 들어옵니다.
0
133
1
게시물 업로드 시 userId가 undefined로 들어가는 오류
0
119
1
useSuspenseQuery 사용 시 SSR 401 이슈 관련
0
172
1
리액트 쿼리 useinfinitequery 무한스크롤 구현 시 페이지가 이동할 경우 데이터가 보존되게 할 수 있나요??
0
184
3
폴링이 필요없는 이유
0
93
2
next Request Memoization과 react cache
0
110
2
seo 최적화 기준은 데이터 fetching인가요 아님 데이터 렌더링인가요?
0
84
2
next.js 서버fetch 에러 fallback ui 구현 방법
0
173
2
프레임워크 여론 파악법
0
125
2
필터옵션이 많은 페이지에서 서버 fetch를 하는게 맞는걸까요??
0
103
2
서버 fetch suspense 로 감싸고 새로고침 시 잠시 빈 화면이 노출된 후 fallback ui가 노출됩니다.
0
102
2
template.tsx 내 서버fetch 응답값과 클라이언트 컴포넌트 상태값 싱크가 맞지 않는 이슈
0
66
2
Auth.js 사용 시 authorize 함수가 호출되지 않습니다
0
132
2
next.js 에서 로그인에 관하여
0
138
1
Next의 route handler에 대한 질문이 있습니다.
0
101
2
게시판 리스트 만들때 use client를 어디서부터 집어넣어야할지 모르겠습니다
0
98
2
프라이빗 폴더를 해야 하는 이유가 모호한 것 같아요.
0
85
2
vanilla-extract 못찾는 문제
0
230
2
fetch 캐싱과 revalidate 관련
0
85
2





