On this page

Common Objects

History
inspector.close(): void

Deactivates the inspector. If there are active connections, they are forcibly terminated. Blocks until the inspector server has fully stopped.

Type:Object
An object to send messages to the remote inspector console.

The inspector console does not have API parity with Node.js console.

inspector.open(port?, host?, wait?): Disposable
Attributes
port?:number
Port to listen on for inspector connections. Optional. Default: what was specified on the CLI.
host?:string
Host to listen on for inspector connections. Optional. Default: what was specified on the CLI.
wait?:boolean
Block until a client has connected. Optional. Default: false.
Returns:Disposable
A Disposable that calls inspector.close().

Activate inspector on host and port. Equivalent to node --inspect=[[host:]port], but can be done programmatically after node has started.

If wait is true, will block until a client has connected to the inspect port and flow control has been passed to the debugger client.

See the security warning regarding the host parameter usage.

inspector.url(): string | undefined
Returns:string | undefined

Return the URL of the active inspector, or undefined if there is none.

$ node --inspect -p 'inspector.url()'
Debugger listening on ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34
For help, see: https://nodejs.org/learn/getting-started/debugging
ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34

$ node --inspect=localhost:3000 -p 'inspector.url()'
Debugger listening on ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a
For help, see: https://nodejs.org/learn/getting-started/debugging
ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a

$ node -p 'inspector.url()'
undefined
M

inspector.waitForDebugger

History
inspector.waitForDebugger(): void

Blocks until a client (existing or connected later) has sent Runtime.runIfWaitingForDebugger command.

An exception will be thrown if there is no active inspector.