8000 Crashes when tsconfig.json `compilerOptions` key is not provided, when using next.config.ts · Issue #75699 · vercel/next.js · GitHub
[go: up one dir, main page]

Skip to content
Crashes when tsconfig.json compilerOptions key is not provided, when using next.config.ts #75699
@lavelle

Description

@lavelle

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/stoic-joji-4sljq7?file=%2Ftsconfig.json%3A5%2C1

To Reproduce

  1. Use next.config.ts in Next 15
  2. Have a tsconfig.json without a compilerOptions key

for example, we have

{
  "extends": ["tsconfig/base.json", "tsconfig/nextjs.json"],
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"],
}

where compilerOptions is defined in base.json, but not directly in the file.

  1. Run next dev
  2. See this error
/Users/giles/code/retool-web/node_modules/.pnpm/next@15.1.6_@babel+core@7.26.0_babel-plugin-macros@3.1.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_sass@1.80.5/node_modules/next/dist/build/next-config-ts/transpile-config.js:16
    const resolvedBaseUrl = (0, _nodepath.join)(cwd, compilerOptions.baseUrl ?? '.');
                                                                     ^

TypeError: Cannot read properties of undefined (reading 'baseUrl')
    at resolveSWCOptions (/Users/giles/code/retool-web/node_modules/.pnpm/next@15.1.6_@babel+core@7.26.0_babel-plugin-macros@3.1.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_sass@1.80.5/node_modules/next/dist/build/next-config-ts/transp
71F8
ile-config.js:16:70)
    at transpileConfig (/Users/giles/code/retool-web/node_modules/.pnpm/next@15.1.6_@babel+core@7.26.0_babel-plugin-macros@3.1.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_sass@1.80.5/node_modules/next/dist/build/next-config-ts/transpile-config.js:51:28)
    at async loadConfig (/Users/giles/code/retool-web/node_modules/.pnpm/next@15.1.6_@babel+core@7.26.0_babel-plugin-macros@3.1.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_sass@1.80.5/node_modules/next/dist/server/config.js:771:36)
    at async Module.nextDev (/Users/giles/code/retool-web/node_modules/.pnpm/next@15.1.6_@babel+core@7.26.0_babel-plugin-macros@3.1.0_react-dom@19.0.0_react@19.0.0__react@19.0.0_sass@1.80.5/node_modules/next/dist/cli/next-dev.js:190:14)

Coming from here https://github.com/vercel/next.js/blob/canary/packages/next/src/build/next-config-ts/transpile-config.ts#L53

Current vs. Expected behavior

Expected Next to work without this key

Actually it crashed.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6031
  Available memory (MB): 36864
  Available CPU cores: 14
Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: N/A
  pnpm: 9.14.2
Relevant Packages:
  next: 15.1.6 // Latest available version is detected (15.1.6).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

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

TypeScript

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

next dev (local), next build (local), next start (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeScriptRelated to types with Next.js.linear: nextConfirmed issue that is tracked by the Next.js team.locked

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0