Skip to content

Module not found: Can't resolve '_http_common' #70262

@kettanaito

Description

@kettanaito

Link to the code that reproduces this issue

mswjs/msw#2291

To Reproduce

Please follow the reproduction steps in the linked issue above.

Current vs. Expected behavior

Current

Next.js throws an error, unable to import a built-in _http_common module in Node.js.

Expectd

Next.js properly imports the built-in module.

Provide environment information

Irrelevant, this is a webpack configuration issue.

Which area(s) are affected? (Select all that apply)

Developer Experience, Runtime, Webpack

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed)

Additional context

I believe this is caused by the Next's default webpack config not listing _http_common in config.externals.

Any thoughts on listing all built-in Node.js modules as external?

{
  // All built-in modules in Node.js must be treated as external.
  externals: require('module').builtinModules
}

I'm proposing this because contributors report that adding _http_common into config.externals helps them. This should be handled on Next's side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RuntimeRelated to Node.js or Edge Runtime with Next.js.WebpackRelated to Webpack with Next.js.bugIssue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions