Next.js エラー辞典
エラー文をそのまま貼って探せるようにしています。直し方だけでなく、なぜ起きたのかまで書いてあります。
- Module not found: Can't resolve 'fs' の直し方Error: Module not found: Can't resolve 'fs' Import trace: Server Component: ./app/view.tsx ./app/page.tsx https://nextjs.org/docs/messages/module-not-found 確認 3 問 →
- Cookies can only be modified の直し方Error: Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options 確認 3 問 →
- generateStaticParams で cookies が使えないError: Route /[slug] used `cookies()` inside `generateStaticParams`. This is not supported because `generateStaticParams` runs at build time without an HTTP request. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context 確認 3 問 →
- createContext を Server Component で使えないError: You're importing a module that depends on `createContext` into a React Server Component module. This API is only available in Client Components. To fix, mark the file (or its parent) with the `"use client"` directive. Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client 確認 3 問 →
- Dynamic server usage の読み方と消し方Error: Dynamic server usage: Route / couldn't be rendered statically because it used `cookies`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error 確認 3 問 →
- next.config の eslint が使えない(Next.js 16)⚠ `eslint` configuration in next.config.ts is no longer supported. See more info here: https://nextjs.org/docs/app/api-reference/cli/next#next-lint-options ⚠ Invalid next.config.ts options detected: ⚠ Unrecognized key(s) in object: 'eslint' next.config.ts(2,34): error TS2353: Object literal may only specify known properties, and 'eslint' does not exist in type 'NextConfig'. 確認 3 問 →
- Event handlers cannot be passed の直し方Error: Event handlers cannot be passed to Client Component props. {items: [...], onAdd: function f} ^^^^^^^^^^ If you need interactivity, consider converting part of this to a Client Component. 確認 3 問 →
- Failed to type check の直し方と ignoreBuildErrorsapp/page.tsx(2,9): error TS2322: Type 'string' is not assignable to type 'number'. Failed to type check. 確認 3 問 →
- Functions cannot be passed directly の直し方Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it. {value: 1200, format: function format} ^^^^^^^^^^^^^^^ 確認 3 問 →
- Hydration failed の直し方Hydration failed because the server rendered text didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used: - A server/client branch `if (typeof window !== 'undefined')`. - Variable input such as `Date.now()` or `Math.random()` which changes each time it's called. - Date formatting in a user's locale which doesn't match the server. - External changing data without sending a snapshot of it along with the HTML. - Invalid HTML tag nesting. 確認 3 問 →
- useState・useRouter を Server Component で使えないError: You're importing a module that depends on `useState` into a React Server Component module. This API is only available in Client Components. To fix, mark the file (or its parent) with the `"use client"` directive. 確認 3 問 →
- use client のページで metadata を export できないError: You are attempting to export "metadata" from a component marked with "use client", which is disallowed. "metadata" must be resolved on the server before the page component is rendered. Keep your page as a Server Component and move Client Component logic to a separate file. Read more: https://nextjs.org/docs/app/api-reference/functions/generate-metadata#why-generatemetadata-is-server-component-only 確認 3 問 →
- output export で generateStaticParams が無いと言われるError: Page "/blog/[slug]" is missing "generateStaticParams()" so it cannot be used with "output: export" config. See more info here: https://nextjs.org/docs/messages/generate-static-params 確認 3 問 →
- next/headers を Client Component で使えないError: You're importing a module that depends on "next/headers" into a React Client Component module. This API is only available in Server Components but one of its parents is marked with "use client", so this module is also a Client Component. 確認 3 問 →
- next/image の hostname is not configured の直し方Error: Invalid src prop (https://example.com/a.png) on `next/image`, hostname "example.com" is not configured under images in your `next.config.js` 確認 3 問 →
- next/image の width が無いときの直し方Error: Image with src "/a.png" is missing required "width" property. 確認 3 問 →
- redirect が効かない(NEXT_REDIRECT)の直し方Error: NEXT_REDIRECT 確認 3 問 →
- NextRouter was not mounted の直し方Error: NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted 確認 3 問 →
- Only plain objects の直し方Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported. 確認 3 問 →
- params が undefined になる原因と直し方Error: Route "/[slug]" used `params.slug`. `params` is a Promise and must be unwrapped with `await` or `React.use()` before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis 確認 3 問 →
- Error occurred prerendering page の読み方Error occurred prerendering page "/about". Read more: https://nextjs.org/docs/messages/prerender-error Error: cms-timeout Export encountered an error on /about/page: /about, exiting the build. 確認 3 問 →
- during render which is unsupported の直し方Error: Route / used "revalidatePath /" during render which is unsupported. To ensure revalidation is performed consistently it must always happen outside of renders and cached functions. 確認 3 問 →
- revalidateTag の第2引数と updateTag(Next.js 16)"revalidateTag" without the second argument is now deprecated, add second argument of "max" or use "updateTag". See more info here: https://nextjs.org/docs/messages/revalidate-tag-single-arg 確認 3 問 →
- Server Actions must be async の直し方Error: Server Actions must be async functions. Error: Only async functions are allowed to be exported in a "use server" file. Error: A "use server" file can only export async functions, found object. 確認 3 問 →
- useSearchParams を Suspense で囲まないと止まるuseSearchParams() should be wrapped in a suspense boundary at page "/find". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout Error occurred prerendering page "/find". Export encountered an error on /find/page: /find, exiting the build. 確認 3 問 →
- window・document is not defined の直し方ReferenceError: window is not defined Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /page: /, exiting the build. 確認 3 問 →