Skip to content

turbopack: module not found in commonjs packageΒ #86458

@aulonm

Description

@aulonm

Link to the code that reproduces this issue

https://github.com/aulonm/nextjs-16-turbopack-bug-repro-repo/tree/build-bug

To Reproduce

  1. pnpm i
  2. pnpm build:packages
  3. pnpm build

Current vs. Expected behavior

Current behavior

Next build stopped working after we upgraded next from 16.0.2 to 16.0.3

Getting module not found on one of our internal packages. I've managed to create a reproduction repo (branch build-bug). We create our own logger that is built in commonjs since we have some internal web apps that are still expecting it to be cjs.

This has worked perfectly fine, but suddenly it stopped working and we don't really know why. Could be our package has a bug, but it works perfectly fine with webpack as well.

Expected behavior

next build should work as it did in 16.0.2

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Thu Nov 13 23:35:49 PST 2025; root:xnu-12377.61.11~7/RELEASE_ARM64_T6041
  Available memory (MB): 24576
  Available CPU cores: 14
Binaries:
  Node: 22.13.0
  npm: 11.5.1
  Yarn: N/A
  pnpm: 10.22.0
Relevant Packages:
  next: 16.0.3 // Latest available version is detected (16.0.3).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Turbopack

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

next build (local)

Additional context

tbh not sure if its commonjs problem or not

I've managed to find the canary version that introduced these problems for us. It started at 16.0.2-canary.7, hope this helps. Everything before that canary version works perfectly fine

Console spits out:

./node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/test/helper.js:33:15
Module not found: Can't resolve 'why-is-node-running'
  31 |
  32 | if (process.env.SKIP_PROCESS_EXIT_CHECK !== 'true') {
> 33 |   const why = require('why-is-node-running')
     |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  34 |   setInterval(why, 10000).unref()
  35 | }
  36 |



Import trace:
  Server Component:
    ./node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/test/helper.js
    ./node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/index.js
    ./node_modules/.pnpm/pino@10.1.0/node_modules/pino/lib/transport.js
    ./node_modules/.pnpm/pino@10.1.0/node_modules/pino/pino.js
    ./packages/utils/dist/logger.js
    ./apps/web/app/logger.ts
    ./apps/web/app/page.tsx

https://nextjs.org/docs/messages/module-not-found


    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
    at <unknown> (https://nextjs.org/docs/messages/module-not-found)
/Users/aulon/dev/personal/monorepo-transpile-repro-repo/apps/web:

Metadata

Metadata

Assignees

No one assigned

    Labels

    TurbopackRelated to Turbopack with Next.js.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions