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 🙏

© 2025 – Pkg Stats / Ryan Hefner

modman

v1.0.0

Published

Module Manager

Readme

node-modman

Module Manager

Installation

npm i modman

What is it?

Modman is a module that lets you control Node.js modules in a sandbox, based off of "vm2".

You can control any module/package, from simply disallowing usage of some FS functions, to controlling how NPM packages can be used in code.

How do I use it?

Here is a basic example:

var modman = require('modman');
var sandbox = modman({
  permissions: {
    "fs.unlinkSync": false,
    "fs.unlink": false,
    "fs.readFileSync": true,
    "fs.readFile": true,
    "fs.writeFileSync": true,
    "fs.writeFile": true
  },
  modules: ['@colors/colors']
});

sandbox(function(){
  var colors = require('@colors/colors')
  var fs = require('fs');

  console.log(colors.blue('Hello, World!')); // "Hello, World!" in blue color
  fs.unlinkSync('index.js'); // gives error
})

Let's break this down.

"permissions": {
    "fs.unlinkSync": false,
    "fs.unlink": false,
    "fs.readFileSync": true,
    "fs.readFile": true,
    "fs.writeFileSync": true,
    "fs.writeFile": true
}

The "permissions" entry is an object filled with the module and functions that have permissions set.

All entry names are the modules, followed by a dot, followed by the function to control.

If a function is denied access, when it is ran, it will say this and stop execution of the sandbox:

Error: Function not allowed in this context.
    at Object.ota.<computed>.<computed> [as unlinkSync] (/home/runner/sanel/index.js:21:52)
    at ReadOnlyHandler.apply (/home/runner/sanel/node_modules/vm2/lib/bridge.js:479:11)
    at vm.js:5:6
    at vm.js:6:3
    at BaseHandler.apply (/home/runner/sanel/node_modules/vm2/lib/bridge.js:479:11)
    at NodeVM.run (/home/runner/sanel/node_modules/vm2/lib/nodevm.js:425:23)
    at /home/runner/sanel/index.js:73:18
    at Object.<anonymous> (/home/runner/sanel/index.js:90:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)

However, if it is allowed, you can use it as normal.

If a permission is not defined, then the function cannot be used. To make it usable, set the permission to true.

  modules: ['@colors/colors']

The "modules" array is so you can include certain modules in the sandbox. It is recommended to use this only for custom modules, as you can include built-ins using the "permissions" entry.

sandbox(function(){
  var colors = require('@colors/colors')
  var fs = require('fs');

  console.log(colors.blue('Hello, World!')); // "Hello, World!" in blue color
  fs.unlinkSync('index.js'); // gives error
})

The "sandbox" function is from the permissions and external modules we set. When run, it will run the code inside the function inside the sandbox, and not run it using fn(). No variables outside the code can be used in the sandbox.

Documentation

modman()

modman({...})

Returns: function

Arguments: (1): array

  • permissions: required
  • modules: optional

sandbox(function)

sandbox(function(){
  ...
})

Returns: nothing

Arguments: (1): function