nextjs - 💡(How to fix) Fix Turbopack: misdetected workspace root (from stray parent lockfile) causes RAM exhaustion (40+ GB) and infinite module-resolution retry on first request [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#92978Fetched 2026-04-19 15:03:46
View on GitHub
Comments
1
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×2commented ×1issue_type_added ×1

Error Message

Error: Can't resolve 'tailwindcss' in 'C:\Users\BobCleaner\Desktop' at finishWithoutResolve (...\enhanced-resolve\lib\Resolver.js:587:18) ... details: "resolve 'tailwindcss' in 'C:\Users\BobCleaner\Desktop'\n" + ' Parsed request is a module\n' + ' No description file found in C:\Users\BobCleaner\Desktop or above\n' + ' resolve as module\n' + " C:\Users\BobCleaner\Desktop\node_modules doesn't exist or is not a directory\n" + " C:\Users\BobCleaner\node_modules doesn't exist or is not a directory\n" + " C:\Users\node_modules doesn't exist or is not a directory\n" + " C:\node_modules doesn't exist or is not a directory"

Fix Action

Fix / Workaround

Mitigation that works:

  • Deleting the orphan C:\Users\<name>\package-lock.json — OR —

  • Setting turbopack.root: __dirname in next.config.ts

  • Tailwind v4 via @tailwindcss/postcss (the default setup from create-next-app)

  • postcss.config.mjs:

    const config = {
      plugins: {
        "@tailwindcss/postcss": {},
      },
    };
    export default config;
  • next.config.ts (after mitigation):

    const nextConfig: NextConfig = {
      turbopack: { root: __dirname },
      experimental: {
        serverActions: { bodySizeLimit: "6mb" },
      },
      // ...
    };

Code Example

{
     "name": "BobCleaner",
     "lockfileVersion": 3,
     "requires": true,
     "packages": {}
   }

---

npx create-next-app@latest myapp

---

C:\Users\<name>\package-lock.json   <-- orphan
   C:\Users\<name>\Desktop\myapp\
       package.json
       package-lock.json
       postcss.config.mjs
       node_modules\
       ...

---

Error: Can't resolve 'tailwindcss' in 'C:\Users\BobCleaner\Desktop'
    at finishWithoutResolve (...\enhanced-resolve\lib\Resolver.js:587:18)
    ...
  details: "resolve 'tailwindcss' in 'C:\\Users\\BobCleaner\\Desktop'\n" +
    '  Parsed request is a module\n' +
    '  No description file found in C:\\Users\\BobCleaner\\Desktop or above\n' +
    '  resolve as module\n' +
    "    C:\\Users\\BobCleaner\\Desktop\\node_modules doesn't exist or is not a directory\n" +
    "    C:\\Users\\BobCleaner\\node_modules doesn't exist or is not a directory\n" +
    "    C:\\Users\\node_modules doesn't exist or is not a directory\n" +
    "    C:\\node_modules doesn't exist or is not a directory"

---

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Enterprise
  Available memory (MB): 65297
  Available CPU cores: 32
Binaries:
  Node: 24.14.1
  npm: 11.11.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.2.4 // Latest available version is detected (16.2.4).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A

---

const config = {
    plugins: {
      "@tailwindcss/postcss": {},
    },
  };
  export default config;

---

const nextConfig: NextConfig = {
    turbopack: { root: __dirname },
    experimental: {
      serverActions: { bodySizeLimit: "6mb" },
    },
    // ...
  };
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/MrMyNameMaster/next-turbopack-ram-repro

To Reproduce

Environment setup (the trigger):

  1. Create an empty/orphan package-lock.json in a parent directory of your project. This can happen accidentally by running npm install in your home folder. Example content:

    {
      "name": "BobCleaner",
      "lockfileVersion": 3,
      "requires": true,
      "packages": {}
    }

    Location: C:\Users\<name>\package-lock.json (no package.json beside it)

  2. Create a Next.js 16 project in a subdirectory, e.g. C:\Users\<name>\Desktop\myapp:

    npx create-next-app@latest myapp

    Use App Router + Tailwind v4 (@tailwindcss/postcss).

  3. Project structure:

    C:\Users\<name>\package-lock.json   <-- orphan
    C:\Users\<name>\Desktop\myapp\
        package.json
        package-lock.json
        postcss.config.mjs
        node_modules\
        ...

Steps:

  1. cd into the project folder and run npm run dev.
  2. Next.js prints the expected warning about multiple lockfiles and picks C:\Users\<name>\ as the inferred workspace root.
  3. Open http://localhost:3000 in a browser.
  4. Observe:
    • Compiler throws Can't resolve 'tailwindcss' in 'C:\Users\<name>\Desktop' repeatedly
    • Node workers start spawning and RAM usage grows unbounded (observed: one parent Node process reaching 43,516 MB, dozens of child workers, see screenshot)
    • The machine becomes unresponsive if not killed

Mitigation that works:

  • Deleting the orphan C:\Users\<name>\package-lock.json — OR —
  • Setting turbopack.root: __dirname in next.config.ts

Either fix makes the dev server behave normally.

Current vs. Expected behavior

Current behavior:

When Next.js infers a workspace root from a stray parent package-lock.json, module resolution for CSS/PostCSS-related imports (e.g. @import "tailwindcss") is performed relative to the wrong root. The resolver (enhanced-resolve) walks up from C:\Users\<name>\DesktopC:\Users\<name>C:\UsersC:\ looking for node_modules, never finding one, and throws:

Error: Can't resolve 'tailwindcss' in 'C:\Users\BobCleaner\Desktop'
    at finishWithoutResolve (...\enhanced-resolve\lib\Resolver.js:587:18)
    ...
  details: "resolve 'tailwindcss' in 'C:\\Users\\BobCleaner\\Desktop'\n" +
    '  Parsed request is a module\n' +
    '  No description file found in C:\\Users\\BobCleaner\\Desktop or above\n' +
    '  resolve as module\n' +
    "    C:\\Users\\BobCleaner\\Desktop\\node_modules doesn't exist or is not a directory\n" +
    "    C:\\Users\\BobCleaner\\node_modules doesn't exist or is not a directory\n" +
    "    C:\\Users\\node_modules doesn't exist or is not a directory\n" +
    "    C:\\node_modules doesn't exist or is not a directory"

Instead of failing once with a clear, actionable error, the dev server:

  1. Retries / respawns worker processes continuously.
  2. The file watcher appears to scan the entire inferred parent tree (C:\Users\<name>\), which on a normal Windows user profile contains tens of GB of files (Documents, Downloads, AppData, OneDrive, etc.).
  3. RAM usage grows without any cap. In my case, one parent Node process reached 43.5 GB within seconds, with 20+ child workers. This can OOM-crash or freeze a machine with less RAM.

Screenshot of Task Manager during the incident is attached below. <img width="1112" height="791" alt="Image" src="https://github.com/user-attachments/assets/32647ffe-0a34-4a63-8a1e-dedaa0c14880" />

Expected behavior:

  1. Fail fast, fail once. If a module cannot be resolved during compilation, emit a single clear error and stop — do not respawn workers or retry in a hot loop.
  2. Memory safeguard. Turbopack / Next.js workers should have an upper bound on RAM usage; a single dev session should never be able to allocate 40+ GB.
  3. Respect turbopack.root. When turbopack.root is explicitly configured, all downstream resolvers (PostCSS / enhanced-resolve / file watcher scope) should honor it.
  4. Stricter root detection. An empty / orphan package-lock.json with no sibling package.json should not be treated as a workspace root. At minimum, the warning about multiple lockfiles should be promoted to an error, or the detection should prefer the lockfile nearest to the current working directory rather than the outermost one.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Enterprise
  Available memory (MB): 65297
  Available CPU cores: 32
Binaries:
  Node: 24.14.1
  npm: 11.11.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.2.4 // Latest available version is detected (16.2.4).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

CSS, Turbopack

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

next dev (local)

Additional context

Configuration details:

  • Tailwind v4 via @tailwindcss/postcss (the default setup from create-next-app)
  • postcss.config.mjs:
    const config = {
      plugins: {
        "@tailwindcss/postcss": {},
      },
    };
    export default config;
  • next.config.ts (after mitigation):
    const nextConfig: NextConfig = {
      turbopack: { root: __dirname },
      experimental: {
        serverActions: { bodySizeLimit: "6mb" },
      },
      // ...
    };

Why this matters for Windows users specifically:

On Windows it is extremely common to accidentally create package-lock.json in C:\Users\<name>\ by running npm install in the default PowerShell/CMD starting directory. The user has no obvious reason to suspect this file exists, and the symptom (Tailwind can't resolve + RAM explosion) is very far from the actual cause (orphan lockfile in home folder). The error message contains no hint pointing to the lockfile.

Severity:

This is not just a confusing error — it is an uncontrolled resource exhaustion that can make a developer machine unusable. On machines with less RAM than mine (I have 64 GB), this would OOM-kill the session or trigger a BSOD/hang before the user can react.

Suggested fixes (in order of impact):

  1. Hard cap on Turbopack worker memory / stop respawning on unresolvable modules.
  2. When turbopack.root is set explicitly in config, skip the multi-lockfile inference entirely.
  3. Detect and ignore "empty" package-lock.json files (no packages / no package.json sibling) during root inference, or at least warn loudly.
  4. In the multi-lockfile warning, prefer the lockfile closest to the CWD instead of the outermost one.

I have not yet tested against next@canary — will update if I find the exact canary that introduced the behavior.

extent analysis

TL;DR

To fix the issue, set turbopack.root: __dirname in next.config.ts to prevent Next.js from inferring a workspace root from a stray parent package-lock.json.

Guidance

  • Verify that there are no stray package-lock.json files in parent directories of your project, as these can cause Next.js to infer an incorrect workspace root.
  • If a stray package-lock.json file is found, delete it or set turbopack.root: __dirname in next.config.ts to override the inferred root.
  • To prevent similar issues in the future, consider adding a check to your project's setup script to ensure that no stray package-lock.json files exist in parent directories.
  • If you are unable to delete the stray package-lock.json file, you can try setting turbopack.root to a specific directory to override the inferred root.

Example

// next.config.ts
const nextConfig: NextConfig = {
  turbopack: { root: __dirname },
  // ... other config options ...
};

Notes

This fix assumes that the issue is caused by a stray package-lock.json file in a parent directory of the project. If the issue persists after applying this fix, further investigation may be necessary to determine the root cause.

Recommendation

Apply the workaround by setting turbopack.root: __dirname in next.config.ts, as this is a simple and effective way to prevent Next.js from inferring an incorrect workspace root.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix Turbopack: misdetected workspace root (from stray parent lockfile) causes RAM exhaustion (40+ GB) and infinite module-resolution retry on first request [1 comments, 1 participants]