diff --git a/bin/next b/bin/next index d79a0123..e189cad7 100755 --- a/bin/next +++ b/bin/next @@ -27,13 +27,18 @@ const commands = new Set([ ]) let cmd = process.argv[2] -let args +let args = [] +let nodeArgs = [] if (new Set(['--version', '-v']).has(cmd)) { console.log(`next.js v${pkg.version}`) process.exit(0) } +if (new Set(process.argv).has('--inspect')) { + nodeArgs.push('--inspect') +} + if (new Set(['--help', '-h']).has(cmd)) { console.log(` Usage @@ -61,7 +66,7 @@ process.env.NODE_ENV = process.env.NODE_ENV || defaultEnv const bin = join(__dirname, 'next-' + cmd) const startProcess = () => { - const proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] }) + const proc = spawn('node', [...nodeArgs, ...[bin], ...args], { stdio: 'inherit', customFds: [0, 1, 2] }) proc.on('close', (code, signal) => { if (code !== null) { process.exit(code)