nextjs - 💡(How to fix) Fix turbopack.root does not apply to PostCSS child process module resolution in npm workspace setup [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#92060Fetched 2026-04-08 01:44:58
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
closed ×1commented ×1labeled ×1locked ×1

When using Next.js 16 (with Turbopack as the default for next build) inside an npm workspace monorepo, setting turbopack.root to the workspace root does not fix module resolution for PostCSS transforms.

The PostCSS transform runs in a separate Node.js child process, and it appears that turbopack.root is not applied to that process's module resolution scope.

Error Message

Build fails with the following error: Error: Turbopack build failed with 1 errors: Error evaluating Node.js code Error: Cannot find module '@tailwindcss/postcss'

Root Cause

It appears that turbopack.root correctly affects Turbopack's main compilation (TS/JS files), but the PostCSS transform — which runs in a separate Node.js child process — does not inherit this scope. The child process module resolution appears to be restricted to the project directory (/app/frontend) rather than the workspace root (/app).

Workaround: Setting NODE_PATH=/app/node_modules as an environment variable before running the build.

Fix Action

Fix / Workaround

Workaround: Setting NODE_PATH=/app/node_modules as an environment variable before running the build.

RAW_BUFFERClick to expand / collapse

Description

When using Next.js 16 (with Turbopack as the default for next build) inside an npm workspace monorepo, setting turbopack.root to the workspace root does not fix module resolution for PostCSS transforms.

The PostCSS transform runs in a separate Node.js child process, and it appears that turbopack.root is not applied to that process's module resolution scope.

Reproduction

Repository structure: ``` /app/ ← workspace root ├── package.json ← npm workspace config ├── node_modules/ ← hoisted packages (includes @tailwindcss/postcss) ├── frontend/ ← Next.js app │ ├── package.json │ ├── next.config.ts │ ├── postcss.config.mjs ← uses @tailwindcss/postcss │ └── src/ └── backend/ └── package.json ```

next.config.ts: ```ts import type { NextConfig } from 'next';

const nextConfig: NextConfig = { output: 'standalone', turbopack: { root: '../', }, };

export default nextConfig; ```

Steps to reproduce:

  1. Set up an npm workspace monorepo with Next.js in a subdirectory
  2. Install dependencies at workspace root (npm ci from root)
  3. Run next build from within the Next.js package directory (e.g. via npm run build --workspace=frontend)

Expected behavior

Setting turbopack.root to the workspace root should expand Turbopack's module resolution scope to include the root node_modules, making PostCSS plugins resolvable.

Actual behavior

Build fails with the following error:

``` Error: Turbopack build failed with 1 errors: ./frontend/src/app/globals.css Error evaluating Node.js code Error: Cannot find module '@tailwindcss/postcss' Require stack:

  • /app/frontend/.next/build/chunks/[root-of-the-server]__048u7-j._.js ```

The warning ⚠ turbopack.root should be absolute, using: /app confirms the root is resolved correctly to /app, yet the PostCSS child process still cannot find @tailwindcss/postcss at /app/node_modules/@tailwindcss/postcss.

Analysis

It appears that turbopack.root correctly affects Turbopack's main compilation (TS/JS files), but the PostCSS transform — which runs in a separate Node.js child process — does not inherit this scope. The child process module resolution appears to be restricted to the project directory (/app/frontend) rather than the workspace root (/app).

Workaround: Setting NODE_PATH=/app/node_modules as an environment variable before running the build.

Environment

  • Next.js version: 16.2.1
  • Node.js version: 20 (alpine)
  • Package manager: npm workspaces
  • OS: Linux (Docker / GitHub Actions)

extent analysis

Fix Plan

To resolve the issue with Turbopack's module resolution scope not being applied to the PostCSS child process, you can use the following approaches:

  • Environment Variable: Set NODE_PATH to the workspace root's node_modules directory before running the build.
  • Modify next.config.ts: Update next.config.ts to include the env configuration to set NODE_PATH.

Example Code

// next.config.ts
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
  output: 'standalone',
  turbopack: {
    root: '../',
  },
  env: {
    NODE_PATH: '../node_modules',
  },
};

export default nextConfig;

Alternatively, you can set the NODE_PATH environment variable before running the build command:

NODE_PATH=/app/node_modules npm run build --workspace=frontend

Verification

After applying the fix, verify that the build process completes successfully without errors related to module resolution. Check that the PostCSS transform can find the required plugins, such as @tailwindcss/postcss.

Extra Tips

  • Ensure that the NODE_PATH environment variable is set correctly and points to the workspace root's node_modules directory.
  • If using a docker or github actions environment, make sure to set the NODE_PATH environment variable in the respective configuration files.
  • Consider updating the next.config.ts file to include the env configuration to set NODE_PATH for a more permanent solution.

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…

FAQ

Expected behavior

Setting turbopack.root to the workspace root should expand Turbopack's module resolution scope to include the root node_modules, making PostCSS plugins resolvable.

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.root does not apply to PostCSS child process module resolution in npm workspace setup [1 comments, 2 participants]