Registry / devops / axios-socks5-agent

axios-socks5-agent

JSON →
library1.0.5jsnpmunverified

A lightweight wrapper that provides SOCKS5 proxy support for Axios by creating http and https agents using socks5-http-client and socks5-https-client. Current stable version is 1.0.5. The package allows custom agent options like keepAlive. It is a simple utility for those needing SOCKS5 proxying in Node.js with Axios. Last update was in 2019; no recent releases.

npm install axios-socks5-agent
INSTALL
IMPORT
SIG · AXIOS-SOCKS5-AGENT
A
axios-socks5-agent
devopsjavascriptv1.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Socks5Agent
import Socks5Agent from 'axios-socks5-agent';
const { Socks5Agent } = require('axios-socks5-agent');
Package uses a single default export. CommonJS require must assign the whole module to a variable; named destructuring does not match the export.
httpAgent
const agent = Socks5Agent({ host, port }); // then use agent.httpAgent
const { httpAgent } = require('axios-socks5-agent');
httpAgent and httpsAgent are properties of the object returned by calling Socks5Agent(options). They are not direct exports.
httpsAgent
const agent = Socks5Agent({ host, port }); // then use agent.httpsAgent
const httpsAgent = Socks5Agent.httpsAgent;
Same as httpAgent; must invoke the function with options to get the agents.

Creates SOCKS5 agents with auth and custom agent options, then uses them in an Axios GET request.

import axios from 'axios'; import Socks5Agent from 'axios-socks5-agent'; const agent = Socks5Agent({ host: '127.0.0.1', port: 9050, agentOptions: { keepAlive: true }, }); async function main() { try { const res = await axios.get('http://wtfismyip.com/json', { httpAgent: agent.httpAgent, httpsAgent: agent.httpsAgent, }); console.log(res.data); } catch (err) { console.error(err); } } main();
Debug
Known issues
gotchaSocks5Agent is a function that must be called with options, not a direct agent or constructor.
fix
Invoke Socks5Agent({ host, port }) to obtain the httpAgent and httpsAgent.
affects: all
gotchaThe package uses deprecated socks5-http-client and socks5-https-client packages which may have security issues.
fix
Consider using modern alternatives like 'socks-proxy-agent'.
affects: all
breakingNo TypeScript typings are shipped despite being mentioned. Actually, the package does ship .d.ts files but they are minimal.
fix
Use @types/axios-socks5-agent if needed, or declare your own module.
affects: <=1.0.5
Errors
Common errors & fixes
Cannot read property 'httpAgent' of undefined
Socks5Agent called without options or returned undefined.
fix
Ensure you call Socks5Agent(options) and capture the return value.
TypeError: Socks5Agent is not a function
Incorrect import (named import) when the module uses default export.
fix
Use import Socks5Agent from 'axios-socks5-agent' (no curly braces).
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
socks5-http-clientrequiredProvides the underlying SOCKS5 HTTP agent implementation
socks5-https-clientrequiredProvides the underlying SOCKS5 HTTPS agent implementation
axiosoptionalPeer dependency; the agents are designed to be used with Axios
Agent activity
11 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
axios-socks5-agent — npm install axios-socks5-agent · libregistry