Skip to content

Commit 0aa3a0f

Browse files
committed
fix(dev): ensure tsconfig.json exists before starting dev server
1 parent 22cf07b commit 0aa3a0f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/nuxi/src/dev/utils.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import defu from 'defu'
1616
import { resolveModulePath } from 'exsolve'
1717
import { toNodeListener } from 'h3'
1818
import { listen } from 'listhen'
19-
import { resolve } from 'pathe'
19+
import { join, resolve } from 'pathe'
2020
import { debounce } from 'perfect-debounce'
2121
import { toNodeHandler } from 'srvx/node'
2222
import { provider } from 'std-env'
@@ -425,10 +425,12 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
425425
}
426426

427427
const kit = await loadKit(this.options.cwd)
428-
await Promise.all([
429-
kit.writeTypes(this.#currentNuxt).catch(console.error),
430-
kit.buildNuxt(this.#currentNuxt),
431-
])
428+
// ensure tsconfigs exist before starting the dev server (vite relies on in the initialisation stage)
429+
const typesPromise = existsSync(join(this.#currentNuxt.options.buildDir, 'tsconfig.json'))
430+
? kit.writeTypes(this.#currentNuxt).catch(console.error)
431+
: await kit.writeTypes(this.#currentNuxt).catch(console.error)
432+
433+
await Promise.all([typesPromise, kit.buildNuxt(this.#currentNuxt)])
432434

433435
if (!this.#currentNuxt.server) {
434436
throw new Error('Nitro server has not been initialized.')

0 commit comments

Comments
 (0)