Reputation: 162
I created a file named joke.js which exports a function. I also have a folder in the directory with the same name joke. In my node file, I want to use require to reference the folder and not the file. How do I tell Node to do that?
So from the index.js in the root, I want to reference the joke directory and not the joke.js file.
I did:
var joke=require('./joke');
P.S.- This question is just out of curiosity of how NodeJS works.
Upvotes: 2
Views: 805
Reputation: 940
require('./joke/')
A trailing slash is used to specify directory in any URI.
Upvotes: 2