diff --git a/packages/nuxi/src/cli-wrapper.ts b/packages/nuxi/src/cli-wrapper.ts index 251ace767371..fcf2a3b2c4f3 100644 --- a/packages/nuxi/src/cli-wrapper.ts +++ b/packages/nuxi/src/cli-wrapper.ts @@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url' import { fork } from 'node:child_process' import type { ChildProcess } from 'node:child_process' +import mri from 'mri' const cliEntry = new URL('../dist/cli-run.mjs', import.meta.url) @@ -33,7 +34,18 @@ function startSubprocess () { start() function start () { - childProc = fork(fileURLToPath(cliEntry)) + const _argv = (process.env.__CLI_ARGV__ ? JSON.parse(process.env.__CLI_ARGV__) : process.argv).slice(2) + const args = mri(_argv, { + boolean: [ + 'no-clear' + ] + }) + const execArguments: string[] = [] + + if (args.inspect) { + execArguments.push('--inspect=0.0.0.0') + } + childProc = fork(fileURLToPath(cliEntry), [], { execArgv: execArguments }) childProc.on('close', (code) => { if (code) { process.exit(code) } }) childProc.on('message', (message) => { if ((message as { type: string })?.type === 'nuxt:restart') {