Chii: Remote Chrome DevTools Framework
Chii is a remote debugging tool that serves as a modern alternative to Weinre, providing a full-featured web inspector experience by integrating the latest Chrome DevTools frontend. It enables developers to inspect and debug web pages across different environments or remote devices by injecting a small `target.js` script into the target page. The package is currently at version 1.15.5, indicating active development with frequent patch releases addressing fixes and minor feature additions (e.g., shadow DOM, dark mode) in its recent 1.x series. Chii operates by running a local server, acting as a proxy between the Chrome DevTools interface and the remote target, offering a familiar and powerful interface for debugging elements, network activity, console logs, and more, which is its primary differentiator against older remote debugging tools.
Common errors
-
ERR_CONNECTION_REFUSED
cause The client device (e.g., mobile phone) cannot connect to the Chii server, often due to incorrect IP address, firewall, or the server not running.fixVerify the Chii server is running (`chii start`). Use the host machine's local network IP address in the target script (`<script src="//YOUR_IP:8080/target.js"></script>`). Check firewall settings on the host machine to allow traffic on the specified port. -
chii: command not found
cause The `chii` command-line tool is not installed globally or is not in your system's PATH.fixInstall Chii globally using `npm install -g chii`. If already installed, ensure your system's PATH includes the directory where npm installs global packages. -
Failed to load resource: net::ERR_CONNECTION_CLOSED (or similar network error for target.js)
cause `target.js` could not be fetched from the Chii server, usually because the server is down, the port is wrong, or the IP address in the script tag is incorrect.fixConfirm the Chii server is active on the expected port (`chii start -p 8080`). Double-check the IP address and port in the `<script src="//host-machine-ip:8080/target.js"></script>` tag in your HTML.
Warnings
- gotcha When debugging from a different device (e.g., a mobile phone), ensure you use the actual IP address of the host machine running Chii in the `<script src="//host-machine-ip:8080/target.js"></script>` tag, not `localhost` or `127.0.0.1`. Firewalls can also block connections, requiring explicit allowance for the specified port.
- gotcha Older versions (prior to 1.15.2) had a 'ws dead loop' issue which could cause WebSocket connections to repeatedly fail, leading to an unstable debugging experience and potential performance degradation.
- gotcha Memory leaks were reported and fixed in versions prior to 1.14.0. Running older versions for extended periods could lead to increased resource consumption and potential crashes of the Chii server.
- gotcha Version 1.15.5 includes a fix for 'invalid route path in koa router', indicating that prior versions might have experienced issues with certain API routes, potentially affecting the functionality of specific DevTools panels or features.
Install
-
npm install chii -
yarn add chii -
pnpm add chii
Imports
- startServer
const { startServer } = require('chii');import { startServer } from 'chii'; - ChiiConstants
import { Constants } from 'chii';import * as ChiiConstants from 'chii/lib/constants';
- ChiiUtil
import { util } from 'chii';import * as ChiiUtil from 'chii/lib/util';
Quickstart
npm install -g chii chii start -p 8080 # In your target HTML file, inject the script: # <script src="//host-machine-ip:8080/target.js"></script> # Then, open http://localhost:8080 in your browser to start debugging. # Replace 'host-machine-ip' with the actual IP address of the machine running Chii if debugging from a different device.