tblobaum / mongoose-troop

plugins for your mongoose schemas.
MIT License
242 stars 29 forks source link

Module doesn't work on windows (path problems in directory) #27

Open alonbardavid opened 11 years ago

alonbardavid commented 11 years ago

I am unable to use the library on windows. The following error occurs: TypeError: Cannot call method 'split' of undefined at node_modules\mongoose-troop\node_modules\directory\lib\directory.js:23:45 at Array.forEach (native) at modulate (node_modules\mongoose-troop\node_modules\directory\lib\directory.js:21:9) at Object. (node_modules\mongoose-troop\index.js:8:21)

looks like when you try to require all the nested indexes under lib, you pass __dirname + /lib/ to the directory module, which eventually tries to split: node_modules\mongoose-troop\lib\acl.js with: node_modules\mongoose-troop/lib/

obviously failing.

matthiasbruns commented 11 years ago

Same problem here - any possible fixes?

var mongoose = require('mongoose')
, troop = require('mongoose-troop');

F:\dev\workspace\QSine\src\portal\node.js\node_modules\mongoose-troop\node_modules\directory\lib\directory.js:23 var filename = path.split(dirname)[1].split(".js")[0] ^ TypeError: Cannot call method 'split' of undefined at F:\dev\workspace\QSine\src\portal\node.js\node_modules\mongoose-troop\node_modules\directory\lib\directory.js:23:45 at Array.forEach (native) at modulate (F:\dev\workspace\QSine\src\portal\node.js\node_modules\mongoose-troop\node_modules\directory\lib\directory.js:21:9) at Object. (F:\dev\workspace\QSine\src\portal\node.js\node_modules\mongoose-troop\index.js:8:21) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17)