Skip to content

Runtime error when a module imports from nuxt/app #34662

@IlyaSemenov

Description

@IlyaSemenov

Environment

Operating system Linux 5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
CPU Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (8 cores)
Node.js version v22.22.0
nuxt/cli version 3.34.0
Package manager [email protected]
Nuxt version 4.4.2
Nitro version 2.13.1
Builder [email protected]
Config compatibilityDate, devtools
Modules -

Reproduction

https://stackblitz.com/edit/nuxt-starter-27yrcyhq

  • pnpm dev → works
  • pnpm build && pnpm preview → surfaces the problem

Describe the bug

When a Nuxt module imports from nuxt/app (such as importing useAsyncData or useRequestHeaders), this leads to runtime crash in production build:

Cannot find module '.../.output/server/node_modules/nuxt/dist/app/types/augments' imported from .../.output/server/node_modules/nuxt/dist/app/index.js

Additional context

  1. Interestingly enough, there is empty augments.js under that path. If I edit the import statement to import from '.../augments.js' (not from '.../augments') it goes further.
  2. With { ssr: false } in nuxt.config.ts, the problem doesn't repeat.
  3. The problem is also gone if the module is added to build.transpile, but that has its own significant drawbacks.

Downstream error: wobsoriano/trpc-nuxt#240

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions