Skip to content

Instantly share code, notes, and snippets.

@groundwater
Created January 23, 2013 18:47
Show Gist options
  • Save groundwater/4611494 to your computer and use it in GitHub Desktop.
Save groundwater/4611494 to your computer and use it in GitHub Desktop.

A Typical Module Layout

package.json
  {
    "main": "index.js"
    ...
  }
index.js
  var lib = require('lib');
  
  // do stuff with 
  // lib.apples
  // lib.bananas
  
  module.exports = {
    // dependency injection magic
  }
lib/
  index.js
    module.exports = {
      apples: require('apples'),
      bananas: require('bananas')
    }
  apples.js
  bananas.js
@isaacs
Copy link

isaacs commented Jan 23, 2013

I think you mean require('./lib') in index.js there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment