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

module-monitor

v1.0.5

Published

Modul-Monitor facilitates automatic reloading of modules in Node.js applications, ensuring real-time updates during development.

Readme

Module-Monitor

Module-Monitor facilitates automatic reloading of modules in Node.js applications, ensuring real-time updates during development.

About The Project

Modul-Monitor is a lightweight utility for Node.js applications that enables automatic reloading of modules when they are modified. It provides a seamless development experience by monitoring specified directories for file changes and refreshing the modules accordingly, ensuring that the latest code changes are always reflected during development.

Features

  • WatchFile: Monitor a single module file for changes, reload dynamically, and handle cleanup.
  • WatchFolder: Monitor an entire directory for module additions, changes, and deletions.
  • Cache Management: Automatic cache-busting and cleanup via query parameters and cleanupModule support.
  • TypeScript Support: Written entirely in TypeScript with typings included.

Installation

npm install module-monitor

Usage

CommonJS

const { WatchFile, WatchFolder } = require("module-monitor");

ES6

import { WatchFile, WatchFolder } from "module-monitor";

WatchFile Example

config.js

function getConfig(){
    return { name: 'XanderID' };
}

export default { getConfig }

index.js

import { WatchFile } from "module-monitor";

const watcher = new WatchFile("./config.js");

watcher.setOnChange(path => {
  console.log(`File changed: ${path}`);
});

watcher.setOnReload((mod, file, err) => {
  if (err) console.error("Reload failed:", err);
  else console.log("Config reloaded:", mod.default.getConfig());
});

watcher.setOnDelete(path => {
  console.log(`File deleted: ${path}`);
});

WatchFolder Example

import { WatchFolder } from "module-monitor";

const commands = new WatchFolder("./commands");

commands.setOnAdd(path => console.log(`Module added: ${path}`));
commands.setOnChange(path => console.log(`Module updated: ${path}`));
commands.setOnDelete(path => console.log(`Module removed: ${path}`));
commands.setOnReload((mod, file, err) => {
  if (err) console.error("Reload error:", err);
  else console.log(`Module loaded:`, mod);
});

Warning

If your modules perform ongoing tasks (e.g., setInterval), implement and export a cleanupModule function to prevent duplicate operations on reload.

Usage Example (e.g., message.js):

let messages = [];
let counter = 1;
const interval = setInterval(() => {
  messages.push(`This is message #${counter}`);
  counter++;
}, 1000);

export async function cleanupModule() {
  clearInterval(interval);
}

This ensures old intervals are cleared before reloading, avoiding duplicate timers or resource leaks.

API

  • WatchFile<T>

    • constructor(filePath: string)
    • setOnChange(cb: (path: string) => void)
    • setOnReload(cb: (mod: T | null, filePath: string, err?: Error) => void)
    • setOnDelete(cb: (path: string) => void)
    • cleanup(): Promise<void>
  • WatchFolder<T>

    • constructor(folderPath: string)
    • setOnAdd(cb: (path: string) => void)
    • setOnChange(cb: (path: string) => void)
    • setOnDelete(cb: (path: string) => void)
    • setOnReload(cb: (mod: T | null, filePath: string, err?: Error) => void)
    • cleanup(): Promise<void>

Contributing

Contributions are welcome! Please open issues and pull requests on GitHub.

License

Distributed under the MIT License.