{"id":13336,"library":"inspector-proxy","title":"Node Inspector Proxy","description":"inspector-proxy is a utility for Node.js that enables proxying the built-in `inspector` debugger sessions. It is designed to simplify debugging scenarios, particularly when working with multiple Node.js processes (e.g., clustered applications, applications managed by `nodemon` or `cfork`) where individual debug ports might be dynamically assigned or need to be consolidated through a single entry point. The current stable version is 1.2.3. The release cadence appears to be low, with infrequent updates primarily focused on dependency maintenance. A key differentiator is its programmatic API, which allows developers to integrate the proxy directly into process management tools, automatically detecting and forwarding debugger connections from child processes to a single, stable proxy URL. It ships with TypeScript types, enhancing its usability in TypeScript projects.","status":"maintenance","version":"1.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/whxaxes/inspector-proxy","tags":["javascript","typescript"],"install":[{"cmd":"npm install inspector-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add inspector-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add inspector-proxy","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary API is a class exported as a CommonJS default. While it ships types, direct ESM default import might be problematic in some environments, or treated as `module.exports` being the default.","wrong":"import InspectorProxy from 'inspector-proxy';","symbol":"InspectorProxy","correct":"const InspectorProxy = require('inspector-proxy');"},{"note":"When using ESM syntax with TypeScript or compatible bundlers, import the class as a default export, not a named export, as it's a CommonJS module's `module.exports`.","wrong":"import { InspectorProxy } from 'inspector-proxy';","symbol":"InspectorProxy","correct":"import InspectorProxy from 'inspector-proxy';"},{"note":"When importing types in TypeScript, use `import type` to ensure the import is erased at compile time and doesn't introduce runtime dependencies.","wrong":"import { InspectorProxyOptions } from 'inspector-proxy';","symbol":"InspectorProxyOptions","correct":"import type { InspectorProxyOptions } from 'inspector-proxy';"}],"quickstart":{"code":"import InspectorProxy from 'inspector-proxy';\nimport cfork from 'cfork';\n\nconst proxy = new InspectorProxy({ port: 9229 });\n\ncfork({\n  exec: './test.js', // Replace with your actual script to be debugged\n  execArgv: [ '--inspect' ],\n  count: 1,\n  refork: true,\n}).on('fork', worker => {\n  let port: string | undefined;\n  worker.process.spawnargs\n    .some(arg => {\n      let matches;\n      // Node.js 6: --inspect=9888\n      // Node.js 8+: --inspect-port=9888 or --inspect (assigns random port)\n      if (arg.startsWith('--inspect') && (matches = arg.match(/\\d+/))) {\n        port = matches[0];\n        return true;\n      }\n      return false;\n    });\n\n  if (!port) {\n    console.error('Could not determine debug port for worker.');\n    return;\n  }\n\n  proxy.start({ debugPort: parseInt(port, 10) })\n    .then(() => {\n      console.log(`\\nProxy URL: ${proxy.url}\\n`);\n      // You can now connect your debugger to this proxy URL\n    })\n    .catch(err => {\n      console.error('Failed to start proxy:', err);\n    });\n});\n\n// Example test.js content (create this file for the example to run)\n/*\nconsole.log('Test script started. Waiting for debugger...');\nlet counter = 0;\nsetInterval(() => {\n  counter++;\n  console.log('Counter:', counter);\n  if (counter === 5) {\n    debugger; // This will pause execution if debugger is attached\n  }\n}, 1000);\n*/","lang":"typescript","description":"Demonstrates how to programmatically start an inspector proxy and connect it to a child process, useful for orchestrating multi-process debugging."},"warnings":[{"fix":"Implement robust argument parsing or consider libraries that abstract away inspector port discovery if more stable integration is needed. For most standard Node.js usages, the current approach is usually sufficient.","message":"The example code for connecting to child processes relies on manually parsing `worker.process.spawnargs` to extract the debug port. This approach can be fragile and prone to breaking if Node.js changes its command-line argument format for the inspector, or if different `inspect` flags (`--inspect`, `--inspect-brk`) are used.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Evaluate the package's existing functionality against your requirements. For stable and mature use cases, this may not be an issue. For evolving needs, consider the long-term support implications.","message":"The `inspector-proxy` package appears to be in maintenance mode, with infrequent updates primarily focused on dependency management rather than active feature development. Users should be aware that new features or rapid bug fixes are unlikely.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"No direct fix needed unless you are targeting extremely old Node.js versions. Always test your application with the specific Node.js version you intend to deploy.","message":"The `engines.node` field specifies `'>=6.0.0'`, indicating compatibility with very old Node.js versions. While this allows broad compatibility, it implies that the package itself may not leverage newer Node.js features or APIs. Users on modern Node.js versions should generally face no issues, but those targeting specific very old versions should ensure their Node.js environment is correctly set up.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Specify a different, unused port for the `InspectorProxy` constructor (e.g., `new InspectorProxy({ port: 9230 })`) or ensure no other application is listening on the desired port.","cause":"The port specified for the inspector proxy (e.g., 9229) is already in use by another process on your system.","error":"Error: listen EADDRINUSE: address already in use :::9229"},{"fix":"Ensure you have installed the package globally using `npm install -g inspector-proxy` or `yarn global add inspector-proxy`. If it's installed locally and you want to use the CLI, prepend `npx` (e.g., `npx inspector-proxy ./test.js`).","cause":"The `inspector-proxy` CLI tool was not found in your system's PATH, typically because it wasn't installed globally or its installation directory isn't included in PATH.","error":"inspector-proxy: command not found"},{"fix":"For JavaScript, use `const InspectorProxy = require('inspector-proxy');`. For TypeScript/ESM, use `import InspectorProxy from 'inspector-proxy';` to correctly import the default export.","cause":"This usually indicates an incorrect import statement, such as attempting to use `import { InspectorProxy } from 'inspector-proxy';` when the package exports a default CommonJS module.","error":"TypeError: InspectorProxy is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}