Use npm install

Explain how to use `npm install` to install 3rd-party libraries to Proxyman Script

Use npm Packages in Proxyman Scripting

Proxyman Scripting supports require() for compatible npm packages installed in Proxyman's Application Support folder. This lets a script reuse popular JavaScript utilities instead of rewriting common logic by hand.

This feature keeps the same require() keyword that Proxyman already uses for built-in libraries and user add-ons. Existing imports such as @libs, @addons, @users, JSON files, text files, and local files continue to work.

Install a package

Open Terminal and install packages into Proxyman's Application Support folder:

  • Install dayjs

$ cd "$HOME/Library/Application Support/com.proxyman.NSProxy"
$ npm install --prefix . dayjs --ignore-scripts --no-audit --no-fund

After installation, the package should exist in:

~/Library/Application Support/com.proxyman.NSProxy/node_modules

Use a package in a script

Use the package name with require():

const dayjs = require("dayjs");

async function onRequest(context, url, request) {
  const formattedDate = dayjs("2026-05-05T13:00:00Z").format("YYYY-MM-DD");
  request.headers["X-Proxyman-Dayjs"] = formattedDate;
  return request;
}

Examples

Format a date with dayjs

Install:

Script:

Normalize text with lodash

Install:

Script:

Validate input with validator

Install:

Script:

Create slugs with slugify

Install:

Script:

Encode data with js-base64

Install:

Script:

Decode HTML entities with he

Install:

Script:

Compatibility

Proxyman runs scripts with JavaScriptCore, not Node.js. npm packages work best when they are pure JavaScript and compatible with CommonJS.

Supported:

  • CommonJS packages loaded with require("package-name")

  • Package entry points from package.json such as main and simple exports

  • Relative imports used inside installed packages, such as require("./helper")

  • JSON files required by packages

Not supported:

  • Node.js built-in modules such as fs, path, crypto, http, or child_process

  • Native .node add-ons

  • Packages that require a full Node.js runtime

  • ESM-only packages that cannot be loaded with CommonJS require()

Node.js native libraries

Proxyman Scripting does not run inside the Node.js runtime. It only uses Node/npm as a package installation tool, then loads compatible JavaScript files with JavaScriptCore.

Because of that, Node.js native libraries are not supported:

  • require("fs"), require("path"), require("crypto"), and other Node.js built-in modules are blocked.

  • require("node:fs") and built-in subpaths such as require("fs/promises") are blocked.

  • Native C/C++ add-ons compiled as .node files are blocked.

  • Packages that call Node-specific APIs such as process.dlopen, filesystem APIs, network sockets, or child processes will not work.

Examples of packages that usually do not work in Proxyman Scripting:

  • sharp

  • sqlite3

  • bcrypt

  • canvas

  • puppeteer

  • packages that require fs, path, crypto, http, https, net, or child_process

Use pure JavaScript packages or packages that provide a CommonJS browser-compatible build instead.

Troubleshooting

If require("dayjs") or another package returns undefined, check that the package is installed in the expected folder:

If node_modules is missing, install again with --prefix .:

The --prefix . option is important because npm may otherwise walk up to a parent package.json and install packages outside Proxyman's folder.

Last updated

Was this helpful?