In my node projcet I build independent modules in to folder with main.js as entry point and locate helpers for that module in the same folder as different files.
Ex:
Aggregator:
|___package.json
|___main.js
|___node_modules
|_____helper1.js
|_____helper2.js
Hence node will resolve all my helpers' dependency for modules [Ex: Aggregator] from local node_modules
folder. Reason for above structure is, I don't need to care about the path on require
I use package.json to specify that entry point is main.js incase require
is for Aggregator
Ex:
//Sample.js
require('Aggregator'); // Resolves to Aggregator/main.js
Ex: package.json of Aggregator module
{
"name": "Aggregator"
, "description": "Returns Aggregates"
, "keywords": ["aggregate"]
, "author": "Tamil"
, "contributors": []
, "dependencies": {
"redis": "0.6.7"
}
, "lib" : "."
, "main" : "./main.js"
, "version" : "1.0"
}
Here what is the dependency column for? I referred this link. My code seems to work even if I specify version of redis as 10000 without any warning. I tried deleting my redis module out of project to test whether node picks it up and resolves the dependency but it didn't. When to use that dependency attribute in package.json? Is it just a note for future reference?
npm version 1.1.0-beta-4 ; node version v0.6.6