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

register-autoload

v1.5.7

Published

Auto register paths for load modules with out node_modules

Downloads

26

Readme

register-autoload

require local modules with absolute path for all folder and folder/lib

###install npm install register-autoload --save

###use

with the given project structure:

    .
    ├── app
    │   └── test.js
    ├── lib
    │   └── serialGenerator
    │       └── index.js
    ├── index.js
    ├── package.json
    └── node_modules
        └── register-autoload
            ├── package.json
            ├── folders-of-project.js
            └── index.js

you can require this from the app directory:

    // only call this once
    // All Folders of Project
    require('register-autoload')();

    // Only folders in project 
    require('register-autoload')(['lib','app']);
    // Outer sintax Only folders in project 
    require('register-autoload')('lib, app');
    //   $project_folder/lib 
    //   $project_folder/app 

    // Only folders in project 
    require('register-autoload')(['lib','app'], ['libs']);
    // Outer sintax Only folders in project 
    require('register-autoload')('lib, app', 'libs');
    //   $project_folder/lib/
    //   $project_folder/app/
    //   $project_folder/../libs/
    //   $project_folder/../libs/
    //   $project_folder/../../libs/
    //    ...
    //   /libs/

    // Only folders in project 
    require('register-autoload')(['lib','app'], ['libs'], true);
    // Outer sintax Only folders in project 
    require('register-autoload')('lib, app', 'libs', 'true');
    //   $project_folder/lib/ 
    //   $project_folder/app/ 
    //   $project_folder/../libs/ 
    //   $project_folder/../../libs/ 
    //    ...
    //   /libs/ 
    //   $project_folder/../
    //   $project_folder/../../
    //    ...
    //   /
    
    // require from node_modules as usual
    let obj = require('test');

    // require from lib with absolute paths
    let obj = require('serialGenerator');
    obj.generate(10000);

problem

require not new locals modules in node can be annoying with relative paths. e.g.

    var modulo = require('../../../lib/modulo');

solution

treat specific application folders like the node_modules folder, so that we can require stuff without ugly relative paths.

sample

$project-folder/index.js

let p = require('register-autoload')('lib, app', 'libs', 'true');
console.log(p);
require('test')();

$project-folder/app/test.js

module.exports = exports = () => {
    let execute = () => {
        var serialGenerator = require('serialGenerator');
        console.log(__dirname, "\n", serialGenerator.generate());
    }
    return execute();
}

$project-folder/lib/serialGenerate/index.js

module.exports.generate = (max = 10000) => {
    return Math.floor(Math.random() * max);
}

OUTPUT: Paths Generated

####[Running] node "index.js"

{ PATHS: [ 
     'c:\\Users\\root\\Projetos\\NodeJS_Sistema_de_Modulos\\lib',
     'c:\\Users\\root\\Projetos\\NodeJS_Sistema_de_Modulos\\app',

     'c:\\Users\\root\\Projetos\\libs',
     'c:\\Users\\root\\libs',
     'c:\\Users\\libs',
     'c:\\libs',

     'c:\\Users\\root\\Projetos',
     'c:\\Users\\root',
     'c:\\Users',
     'c:\\' 
]}

// c:\Users\root\Projetos\NodeJS_Sistema_de_Modulos\app 
// 7249

[Done] exited with code=0 in 1.952 seconds

test

tested so far with node 0.8, 0.10, 0.11, 8

inspiration

https://gist.github.com/branneman/8048520

credits

  • @branneman for the great article on this topic
  • @joelabair for the cool hack