Simplify requiring local modules


100.6.36 months ago5 years agoMinified + gzip package size for @larsthorup/local in KB



npm version Build Status

Simplify requiring local modules

The purpose of this module is to make it easy to keep self-contained Node modules in the same repo as the rest of your app during initial development, in such a way that you can easily convert the module to be a real external module eventually.


npm install @larsthorup/local --save

var local = require('@larsthorup/local');
var config = local('config');


You can optionally declare local modules in dependency order in package.json. If so, local() will verify requests against the declaration, unless NODE_ENV is production:

  "config": {
    "@larsthorup/local": {
      "modules": [

var util = local('util'); // Note: will throw an error

var core = local('core'); // Note: will succeed if in some source file in lib

var lib = local('lib'); // Note: will throw an error if in some source file in core 

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.