Skip to content

NextJS 16 version of turbopack failing to resolve bootstrap imports on Windows #86431

@w7rus

Description

@w7rus

Link to the code that reproduces this issue

https://github.com/w7rus/nextjs16-turbopack-bootstrap-windows

To Reproduce

  1. Use Windows 10/11
  2. Use Node 22.x
  3. npm i
  4. node node_modules/next/dist/bin/next build --turbopack

Current vs. Expected behavior

on step 4. build must succeed, but instead it fails on:

PS C:\Users\admin\Desktop\proj> node node_modules\next\dist\bin\next build --turbopack
   ▲ Next.js 16.0.3 (Turbopack)

   Creating an optimized production build ...

...

> Build error occurred
Error: Turbopack build failed with 1 errors:
./src/styles/my-bootstrap.scss
Error evaluating Node.js code
Error: Can't find stylesheet to import.
     ╷
1753 │ @import "variables-dark"; // TODO: can be removed safely in v6, only here to avoid breaking changes in v5.3
     │         ^^^^^^^^^^^^^^^^
     ╵
  node_modules\bootstrap\scss\_variables.scss 1753:9  @import
  src\styles\my-bootstrap.scss 5:9                    root stylesheet
Caused by: Error: Can't find stylesheet to import.
     ╷
1753 │ @import "variables-dark"; // TODO: can be removed safely in v6, only here to avoid breaking changes in v5.3
     │         ^^^^^^^^^^^^^^^^
     ╵
  node_modules\bootstrap\scss\_variables.scss 1753:9  @import
  src\styles\my-bootstrap.scss 5:9                    root stylesheet
    [at Object.wrapException (C:\Users\admin\Desktop\proj\node_modules\sass\sass.dart.js:2316:47)]
    [at C:\Users\admin\Desktop\proj\node_modules\sass\sass.dart.js:88031:25]
    [at _wrapJsFunctionForAsync_closure.$protected (C:\Users\admin\Desktop\proj\node_modules\sass\sass.dart.js:4984:15)]
    [at _wrapJsFunctionForAsync_closure.call$2 (C:\Users\admin\Desktop\proj\node_modules\sass\sass.dart.js:38319:12)]
    [at _awaitOnObject_closure.call$1 (C:\Users\admin\Desktop\proj\node_modules\sass\sass.dart.js:38307:32)]
    [at Object._rootRunUnary (C:\Users\admin\Desktop\proj\node_modules\sass\sass.dart.js:5402:18)]
    [at StaticClosure.<anonymous> (C:\Users\admin\Desktop\proj\node_modules\sass\sass.dart.js:125885:16)]
    [at _CustomZone.runUnary$2$2 (C:\Users\admin\Desktop\proj\node_modules\sass\sass.dart.js:39750:39)]
    [at _Future__propagateToListeners_handleValueCallback.call$0 (C:\Users\admin\Desktop\proj\node_modules\sass\sass.dart.js:38808:51)]
    [at Object._Future__propagateToListeners (C:\Users\admin\Desktop\proj\node_modules\sass\sass.dart.js:5194:93)]


    at ignore-listed frames

Doing the same on Debian 11 via WSL, with Node 22.x:

w7rus@W7RUS-PC:/mnt/c/Users/admin/Desktop/proj$ node node_modules/next/dist/bin/next build --turbopack
   ▲ Next.js 16.0.3 (Turbopack)

   Creating an optimized production build ...

...

Specified module format (EcmaScript Modules) is not matching the module format of the source code (CommonJs)
The EcmaScript module format was specified in the package.json that is affecting this source file or by using an special extension, but it looks like that CommonJs syntax is used in the source code.
Exports made by CommonJs syntax will lead to a runtime error, since the module is in EcmaScript mode. Either change the "type" field in the package.json or replace CommonJs syntax with EcmaScript import/export syntax in the source file.


 ✓ Compiled successfully in 20.4s
 ✓ Finished TypeScript in 9.7s
 ✓ Collecting page data using 3 workers in 3.1s
 ✓ Generating static pages using 3 workers (4/4) in 4.2s
 ✓ Finalizing page optimization in 9.9s

Route (app)
┌ ○ /
└ ○ /_not-found


○  (Static)  prerendered as static content

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 IoT Enterprise LTSC 2024
  Available memory (MB): 65281
  Available CPU cores: 20
Binaries:
  Node: 22.16.0
  npm: 11.6.3
  Yarn: 1.22.22
  pnpm: N/A
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: standalone

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

Turbopack

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

next build (local), next dev (local)

Additional context

Another quick-fix as mentioned in this comment is to use --webpack on Windows.

PS C:\Users\admin\Desktop\proj> node node_modules\next\dist\bin\next build --webpack
   ▲ Next.js 16.0.3 (webpack)

   Creating an optimized production build ...

...

 ✓ Compiled successfully in 7.0s
 ✓ Finished TypeScript in 1221.4ms
 ✓ Collecting page data using 19 workers in 377.3ms
 ✓ Generating static pages using 19 workers (4/4) in 486.5ms
 ✓ Collecting build traces in 14.8s
 ✓ Finalizing page optimization in 15.2s

Route (app)
┌ ○ /
└ ○ /_not-found


○  (Static)  prerendered as static content

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