Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including indexport with all npm packages installed. Try it out:

var indexport = require("indexport")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

indexport v0.1.1

index.js made DRYer. Exports all the modules in a directory in just one sentence

indexport Build Status

Node's index.js modules made DRYer. Just export all the modules in a directory in one sentence.

Not clear enough? Ok, let me give you an example:

Instead of writting the following index.js file:

module.exports = {
  moduleA: require('./module-a'),
  moduleB: require('./module-b'),
  moduleC: require('./module-c'),
  moduleD: require('./module-d'),

With indexport you can do:

module.exports = require('indexport')(__dirname)

Conclusion: the exported interface are exactly the same.


npm install indexport --save


In your index.js JS file:

module.exports = require('indexport')(__dirname)


indexport(directory) => object

Returns an object map with the exported modules.


MIT - Tomas Aparicio


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free