npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

global-proxy-agent

v1.0.1

Published

A universal proxy agent for Node.js that combines environment-variable-based proxy resolution with smart protocol-aware agent selection. Automatically supports HTTP, HTTPS, SOCKS, and PAC proxies using a modular, runtime-configurable approach. It also pro

Readme

global-proxy-agent

A universal proxy agent for Node.js that combines environment-variable-based proxy resolution with smart protocol-aware agent selection. Automatically supports HTTP, HTTPS, SOCKS, and PAC proxies using a modular, runtime-configurable approach.

Additionally, global-proxy-agent includes a powerful CLI for managing proxy settings directly from the terminal. This allows users to configure proxies, excluded domains, and logging without writing any code.

npm License Under Development Open for Contribution

Installation

To install global-proxy-agent, use npm:

npm i global-proxy-agent

Or with Yarn:

yarn add global-proxy-agent

📦 Usage

1. setupGlobalProxyAgent()

Initializes the global proxy agent system. Should be called before using any global proxy features.

import { setupGlobalProxyAgent } from 'global-proxy-agent';

setupGlobalProxyAgent();

2. bootstrap()

Bootstraps the proxy settings using environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY, etc).

import { bootstrap } from 'global-proxy-agent';

bootstrap();

3. createSmartProxyAgent(url: string): Agent

Creates an HTTP(S) agent for a specific request URL, using the appropriate proxy.

import { createSmartProxyAgent } from 'global-proxy-agent';

const agent = createSmartProxyAgent('https://example.com');

4. resolveProxyForUrl(url: string): string

Returns the resolved proxy URL that would be used for the given request URL.

import { resolveProxyForUrl } from 'global-proxy-agent';

const proxy = resolveProxyForUrl('https://example.com');
console.log(proxy); // e.g., http://myproxy.com:8080

5. setGlobalProxy(proxyUrl: string)

Dynamically sets or updates the global proxy at runtime.

import { setGlobalProxy } from 'global-proxy-agent';

setGlobalProxy('http://my-new-proxy.com:8080');

6. setGlobalNoProxy(domains: string[])

Sets domains to be excluded from the proxy (similar to NO_PROXY behavior).

import { setGlobalNoProxy } from 'global-proxy-agent';

setGlobalNoProxy(['localhost', 'example.com']);

7. globalState

Access to internal config (not typically needed by end users, but useful for debugging or advanced use cases).

import { globalState } from 'global-proxy-agent';

console.log(globalState.proxyUrl);

8. setAgent(agent: Agent)

Override the global agent manually.

import { setAgent } from 'global-proxy-agent';
import { Agent } from 'http';

const customAgent = new Agent();
setAgent(customAgent);

9. getCurrentProxy(): string

Returns the current global proxy URL.

import { getCurrentProxy } from 'global-proxy-agent';

console.log(getCurrentProxy()); // e.g., 'http://proxy:3128'

10. getExcludedDomains(): string[]

Returns the list of domains excluded from proxying.

import { getExcludedDomains } from 'global-proxy-agent';

console.log(getExcludedDomains()); // ['localhost', 'example.com']

11. resetProxySettings()

Resets all proxy settings to defaults.

import { resetProxySettings } from 'global-proxy-agent';

resetProxySettings();

12. enableLogging() / disableLogging()

Enables or disables internal debug logging.

import { enableLogging, disableLogging } from 'global-proxy-agent';

enableLogging();  // Turn on logs
disableLogging(); // Turn off logs

13. logger

Access the internal logger (uses console.log by default, can be customized).

import { logger } from 'global-proxy-agent';

logger.log('Custom debug message');

CLI Usage

The global-proxy-agent provides a command-line interface to manage your proxy settings easily via terminal.

📥 Install Globally (optional)

npm install -g global-proxy-agent

Or use via npx without installing:

npx global-proxy-agent <command>

🧾 Commands

set-proxy <proxyUrl>

Set the global proxy dynamically.

global-proxy-agent set-proxy http://my-proxy.com:3128

unset-proxy

Remove the global proxy configuration.

global-proxy-agent unset-proxy

set-no-proxy <domains>

Specify comma-separated domains to exclude from proxying.

global-proxy-agent set-no-proxy localhost,example.com

show-config

View the current proxy configuration and excluded domains.

global-proxy-agent show-config

reset

Reset all proxy settings to their default state.

global-proxy-agent reset

enable-logging

Enable verbose logging for debugging.

global-proxy-agent enable-logging

disable-logging

Turn off verbose logging.

global-proxy-agent disable-logging

📌 Example

# Set proxy
global-proxy-agent set-proxy http://proxy.local:8080

# Exclude local dev domains
global-proxy-agent set-no-proxy localhost,dev.local

# Check current settings
global-proxy-agent show-config