Skip to content

Error [InvariantError]: Invariant: The manifests singleton was not initialized. This is a bug in Next.js. #50

@zhh210

Description

@zhh210
> nbks start
(node:4679) ExperimentalWarning: SQLite is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
✔ Starting NodeBooks server...
Using configuration at ~/.config/nodebooks/nodebooks.toml
➜ Open http://localhost:4001
(node:4690) ExperimentalWarning: SQLite is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
⨯ Error [InvariantError]: Invariant: The manifests singleton was not initialized. This is a bug in Next.js.
    at ignore-listed frames
⨯ Error [InvariantError]: Invariant: The manifests singleton was not initialized. This is a bug in Next.js.
    at ignore-listed frames

AI was able to identify the root cause and fix though:

The agent found the root cause. The .next build was produced with Next.js 16.0.7 but the runtime is 16.1.6 — a build/runtime version mismatch causes the manifests singleton to never get initialized.
                                                                                                                                                                                                        
  Let me verify this and try the most targeted fix:                                                                                                                                                     
                                                                                                                                                                                                        
● Read 3 files (ctrl+o to expand)                                                                                                                                                                       
                                                                                                                                                                                                        
● Confirmed. The root cause is a build/runtime version mismatch:                                                                                                                                        
                                                                                                                                                                                                        
  - Build artifacts: compiled with Next.js 16.0.7 (visible in the manifest paths referencing next@16.0.7)                                                                                               
  - Runtime: running Next.js 16.1.6 (what's installed in node_modules)                                                                                                                                  
  - The build also uses Turbopack, which changes manifest path resolution                                                                                                                               
                                                                                                                                                                                                        
  The manifests singleton is never initialized because the 16.1.6 runtime can't properly load the 16.0.7 Turbopack build artifacts.                                                                     
                                                                                                                                                                                                        
  The fix is to update the @nodebooks/server package so its build matches the runtime Next.js version.

I downgraded the Next.js runtime from 16.1.6 to 16.0.7 to match the version used when the nodebooks server was built.                                                                                 
                                                                                                                                                                                                        
  The problem: The @nodebooks/server package ships with pre-built .next artifacts (the compiled frontend) that were built using Next.js 16.0.7 (with Turbopack). But the package declared Next.js 16.1.6
   as its runtime dependency. When the 16.1.6 runtime tried to load the 16.0.7 build artifacts, it couldn't properly initialize the manifests singleton due to internal API changes between versions —
  hence the error.                                                                                                                                                                                      
                  
  The fix was a single command:

  cd /opt/conda/lib/node_modules/@nodebooks/cli/node_modules
  npm install next@16.0.7 --no-save

  This replaced the Next.js 16.1.6 runtime with 16.0.7, so the runtime now matches the pre-built artifacts.

  Caveat: This is a local workaround. If you run npm install -g @nodebooks/cli again, it will reinstall Next.js 16.1.6 and the error will return. The proper fix needs to come from the nodebooks
  maintainers aligning the build and runtime versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions