diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 538acb1e212633..05f2700e0c9206 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -18,7 +18,7 @@ const { internalBinding, NativeModule } = loaderExports; -let getOptionValue; +const { getOptionValue } = NativeModule.require('internal/options'); function startup() { setupTraceCategoryState(); @@ -160,18 +160,6 @@ function startup() { NativeModule.require('internal/inspector_async_hook').setup(); } - getOptionValue = NativeModule.require('internal/options').getOptionValue; - - if (getOptionValue('--help')) { - NativeModule.require('internal/print_help').print(process.stdout); - return; - } - - if (getOptionValue('--completion-bash')) { - NativeModule.require('internal/bash_completion').print(process.stdout); - return; - } - // If the process is spawned with env NODE_CHANNEL_FD, it's probably // spawned by our child_process module, then initialize IPC. // This attaches some internal event listeners and creates: @@ -376,6 +364,18 @@ function startExecution() { return; } + // node --help + if (getOptionValue('--help')) { + NativeModule.require('internal/print_help').print(process.stdout); + return; + } + + // e.g. node --completion-bash >> ~/.bashrc + if (getOptionValue('--completion-bash')) { + NativeModule.require('internal/bash_completion').print(process.stdout); + return; + } + // `node --prof-process` if (getOptionValue('--prof-process')) { NativeModule.require('internal/v8_prof_processor');