#5046·nextra

Nextra 4.6.1 build fails with TypeScript 7: typescript.sys.readFile is undefined

Author: timsun28Created Aug 22, 2026Updated Aug 22, 2026

Summary

A Nextra 4.6.1 docs site fails to build when the project resolves TypeScript 7.0.2. The failure occurs while Nextra processes every MDX file through @shikijs/twoslash / twoslash.

Environment

  • nextra: 4.6.1
  • nextra-theme-docs: 4.6.1
  • next: 16.3.2
  • typescript: 7.0.2
  • pnpm: 9.15.9 on Vercel
  • Vercel production build

Error

TypeError: Cannot read properties of undefined (reading 'readFile')
    at createCacheableFSBackedSystem (.../twoslash/dist/core.mjs:441:43)
    at createTwoslasher (.../twoslash/dist/core.mjs:57:46)
    at transformerTwoslash (.../@shikijs/twoslash/dist/index.mjs:8:5)
    at .../nextra/dist/server/loader.js:43:30

The same error is reported for every MDX file, plus Nextra's page-map/get.js, so it looks like one loader-level compatibility failure rather than invalid MDX content.

In the affected install, typescript.sys is undefined:

javascript
import ts from 'typescript'
console.log(ts.version) // 7.0.2
console.log(ts.sys) // undefined

[email protected] declares a typescript peer range of ^5.5.0, but pnpm still resolved it alongside TypeScript 7.0.2.

Workaround

Pinning TypeScript to 5.9.3 and regenerating pnpm-lock.yaml fixes the Vercel build without any MDX changes.

Expected behavior

Either Nextra should build with the resolved TypeScript version, or installation/build should make the unsupported TypeScript version clear before the loader attempts to process every MDX file.