{"id":14988,"library":"tunnel","title":"Node.js HTTP/HTTPS Tunneling Agent","description":"The `tunnel` package, currently at version 0.0.6, provides `http.Agent` and `https.Agent` implementations specifically designed for tunneling HTTP and HTTPS traffic through various types of proxies (HTTP over HTTP, HTTPS over HTTP, HTTP over HTTPS, HTTPS over HTTPS). It targets extremely old Node.js environments, supporting versions `0.6.11` through `0.7.0`, and `0.7.3` (as indicated by its `engines` field). This package is considered abandoned, with no new releases or maintenance since 2014, and is not compatible with modern Node.js runtimes. Its primary differentiator was its early support for detailed proxy configurations for different tunneling scenarios within the Node.js `http` module ecosystem, but it has been superseded by actively maintained alternatives.","status":"abandoned","version":"0.0.6","language":"javascript","source_language":"en","source_url":"https://github.com/koichik/node-tunnel","tags":["javascript","http","https","agent","proxy","tunnel"],"install":[{"cmd":"npm install tunnel","lang":"bash","label":"npm"},{"cmd":"yarn add tunnel","lang":"bash","label":"yarn"},{"cmd":"pnpm add tunnel","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package exclusively uses CommonJS `require` syntax as it predates widespread Node.js ESM adoption. The `tunnel` variable will hold an object containing the agent creation functions.","wrong":"import tunnel from 'tunnel';","symbol":"tunnel","correct":"const tunnel = require('tunnel');"},{"note":"While CommonJS, direct destructuring of properties like `httpsOverHttp` might not have been a common or reliable pattern in Node.js versions targeted by this package. It's safer to access via `tunnel.httpsOverHttp`.","wrong":"import { httpsOverHttp } from 'tunnel';","symbol":"httpsOverHttp","correct":"const { httpsOverHttp } = require('tunnel');"}],"quickstart":{"code":"const tunnel = require('tunnel');\nconst https = require('https');\n\nconst tunnelingAgent = tunnel.httpsOverHttp({\n  proxy: {\n    host: 'localhost',\n    port: 3128,\n    proxyAuth: process.env.PROXY_AUTH ?? '', // Example: 'user:password'\n    headers: {\n      'User-Agent': 'Node.js Tunnel Example'\n    }\n  }\n});\n\nconst options = {\n  host: 'example.com',\n  port: 443,\n  agent: tunnelingAgent,\n  path: '/',\n  method: 'GET'\n};\n\nconst req = https.request(options, (res) => {\n  console.log(`STATUS: ${res.statusCode}`);\n  console.log(`HEADERS: ${JSON.stringify(res.headers)}`);\n  res.setEncoding('utf8');\n  res.on('data', (chunk) => {\n    console.log(`BODY: ${chunk}`);\n  });\n  res.on('end', () => {\n    console.log('No more data in response.');\n  });\n});\n\nreq.on('error', (e) => {\n  console.error(`problem with request: ${e.message}`);\n});\n\nreq.end();","lang":"javascript","description":"This example demonstrates how to create an `httpsOverHttp` tunneling agent and use it with `https.request` to make a secure HTTP request through an HTTP proxy. It highlights the basic configuration for the proxy settings and includes error handling."},"warnings":[{"fix":"Do not use this package. Migrate to actively maintained alternatives such as `https-proxy-agent` or `socks-proxy-agent`.","message":"The `tunnel` package is abandoned and last updated in 2014. It explicitly targets Node.js versions `<=0.7.x` and is incompatible with all modern Node.js versions (>=1.0.0), leading to runtime errors.","severity":"breaking","affected_versions":"all"},{"fix":"Immediately cease use of this package in production. Replace it with a well-maintained, modern proxy agent library.","message":"Due to its abandonment, this package has not received any security updates. It may contain unpatched vulnerabilities related to network communication, proxy handling, or certificate validation, posing significant security risks.","severity":"breaking","affected_versions":"all"},{"fix":"This package cannot be made compatible with modern Node.js. Use contemporary libraries designed for current Node.js APIs.","message":"The API for `http.Agent` and `https.Agent` has evolved significantly since Node.js 0.7.x. Attempting to use `tunnel` with newer Node.js versions will result in `TypeError`s or unexpected behavior due to incompatible method signatures and internal changes.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"This package is incompatible with modern Node.js. Use an alternative like `https-proxy-agent` which is actively maintained and designed for current Node.js versions.","cause":"This error occurs because internal APIs of Node.js's `http.Agent` and `https.Agent` classes changed significantly after the versions supported by the `tunnel` package (<=0.7.x). Modern Node.js versions do not expose or expect the `addRequest` method in the same way.","error":"TypeError: tunnelingAgent.addRequest is not a function"},{"fix":"First, ensure `npm install tunnel` completes successfully. If not, it reinforces that the package is too old or broken. The recommended fix is to abandon this package and use a modern, actively maintained proxy agent library.","cause":"This typically indicates the package is not installed, or npm failed to install it correctly due to compatibility issues with your Node.js version, or the package entry on the registry might be broken for older versions.","error":"Error: Cannot find module 'tunnel'"}],"ecosystem":"npm"}