nextjs - 💡(How to fix) Fix misdetected workspace root (from stray parent lockfile) causes RAM exhaustion (40+ GB) and infinite module-resolution retry on first request [1 comments, 2 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#92977Fetched 2026-04-19 15:03:48
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×3closed ×1commented ×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

I will provide a minimal reproduction shortly. The issue is 100% reproducible with the steps below on a stock create-next-app + Tailwind v4 project.

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.

<img width="1112" height="791" alt="Image" src="https://github.com/user-attachments/assets/8368d70d-4df1-4814-829b-d84bec003a8c" />

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:\Users → [C:](cci:9://file:///:0:0-0:0) 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 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.

Screenshot of Task Manager during the incident: (attach the Task Manager screenshot here)

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. In my testing, the inferred-root warning still affects CSS module resolution even when turbopack.root is set, unless the stray lockfile is physically deleted.
  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, not 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)

Turbopack, CSS

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.

<img width="1112" height="791" alt="Image" src="https://github.com/user-attachments/assets/dbeea255-bafb-4327-86b1-ccada743b08c" />

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 the 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 for stray package-lock.json files in the project's CI/CD pipeline or build process.
  • If the issue persists, try upgrading to the latest version of Next.js or filing an issue with the Next.js team to request a fix for the root inference logic.

Example

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

Notes

The provided fix assumes that the issue is caused by a stray package-lock.json file in a parent directory of the project. If the issue is caused by a different factor, additional debugging may be necessary.

Recommendation

Apply the workaround by setting turbopack.root: __dirname in next.config.ts, as this provides a clear and explicit root for the project and prevents 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 misdetected workspace root (from stray parent lockfile) causes RAM exhaustion (40+ GB) and infinite module-resolution retry on first request [1 comments, 2 participants]