diff --git a/packages/next/src/cli/next-dev.ts b/packages/next/src/cli/next-dev.ts index 549e75bdee751..442e1ed5fa36d 100644 --- a/packages/next/src/cli/next-dev.ts +++ b/packages/next/src/cli/next-dev.ts @@ -161,6 +161,15 @@ const nextDev = async ( portSource: PortSource, directory?: string ) => { + const isTurbopack = Boolean( + options.turbo || options.turbopack || process.env.IS_TURBOPACK_TEST + ) + if (isTurbopack) { + process.env.TURBOPACK = '1' + } + + isTurboSession = isTurbopack + dir = getProjectDir(process.env.NEXT_PRIVATE_DEV_DIR || directory) // Check if pages dir exists and warn if not @@ -238,15 +247,6 @@ const nextDev = async ( hostname: host, } - const isTurbopack = Boolean( - options.turbo || options.turbopack || process.env.IS_TURBOPACK_TEST - ) - if (isTurbopack) { - process.env.TURBOPACK = '1' - } - - isTurboSession = isTurbopack - const distDir = path.join(dir, config.distDir ?? '.next') setGlobal('phase', PHASE_DEVELOPMENT_SERVER) setGlobal('distDir', distDir)