开发手册 欢迎您!
软件开发者资料库

检查工具(Inspector) | Node.js

Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境。Node.js 使用了一个事件驱动、非阻塞式 I/O 的模型,使其轻量又高效。Node.js 的包管理器 npm,是全球最大的开源库生态系统。

Node.js v8.x 中文文档


Inspector#

Stability: 1 - Experimental

The inspector module provides an API for interacting with the V8 inspector.

It can be accessed using:

const inspector = require('inspector');

inspector.open([port[, host[, wait]]])#

  • port Port to listen on for inspector connections. Optional,defaults to what was specified on the CLI.
  • host Host to listen on for inspector connections. Optional,defaults to what was specified on the CLI.
  • wait Block until a client has connected. Optional, defaultsto false.

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

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

inspector.close()#

Deactivate the inspector. Blocks until there are no active connections.

inspector.url()#

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

Class: inspector.Session#

The inspector.Session is used for dispatching messages to the V8 inspectorback-end and receiving message responses and notifications.

Constructor: new inspector.Session()#

Create a new instance of the inspector.Session class. The inspector sessionneeds to be connected through session.connect() before the messagescan be dispatched to the inspector backend.

inspector.Session is an EventEmitter with the following events:

Event: 'inspectorNotification'#