vercel/next.js · error

"next" should not be imported directly, imported in ${module

Error message

"next" should not be imported directly, imported in ${module.parent?.filename}
See more info here: https://nextjs.org/docs/messages/import-next

What it means

Side-effect warning module: importing it logs this warning when the 'next' server entry was imported directly at runtime (module.parent is set), explaining that user code should never import `next` directly; no exception is thrown.

Source

Thrown at packages/next/src/lib/import-next-warning.ts:3

import * as Log from '../build/output/log'

Log.warn(
  `"next" should not be imported directly, imported in ${module.parent?.filename}\nSee more info here: https://nextjs.org/docs/messages/import-next`
)

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Do not import the "next" package directly in your code; use public entry points like next/head, next/link, etc.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/next/src/lib/import-next-warning.ts:3 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/4ea3795589b3dcb8. Report an issue: GitHub.