I've been writing a little prototype app in the cloud9 ide using express and nodejs.
I was going to re-organize some code into a few custom modules but when I attempt to require them I get an error "cannot find module './lib'
The lib folder is in the root of my site directory. I have 1 file in there "test.js" that has a simple demo to try and get this working.
exports.test = function(){
return 'hello world';
};
It doesn't matter if I put require('./lib') or require('./lib/test') in my app.js, it always throws the same error.
Any thoughts?
Two potential errors:
1- require() looks for a file called index.js. So try renaming test.js to index.js might work.
2- Your path is wrong. Is the lib folder in the same folder as the file in which you call the require()?