node.js require cannot find custom module node.js require cannot find custom module javascript javascript

node.js require cannot find custom module


The path is relative to the directory in which you are requireing the files, so it should be something like:

var couch = require('./couch');var config = require('../config');

A bit of clarification, if you write

var couch = require('./couch');

you are trying to require the couch module which resides in the current directory, if you write

var couch = require('couch');

you are trying to require the couch module installed via npm.


Here is how you do it :

var users    = require('./../modules/users');


It must be:

var config = require(../../app/config)var couch = require(./couch) (same directory)