can't find module in parent directory

68 views
Skip to first unread message

Brecht Huang

unread,
Mar 31, 2012, 10:43:54 AM3/31/12
to node...@googlegroups.com
I got error message like this:

Error: Cannot find module '/app/config'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/app/models/index.js:2:11)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
Error: Restarted too many times, bailing.


below is how my files organized.

/app.js
/config.js
/other files..
/models/index.js


In /models/index.js, first I used relative path like this:

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

and it show error message like above, just a litte different in path. I google some artices, find out thate I can't use relative path in Nodester, it must use absolute path, so I change path to :

require('/app/config').config

or 

require('/config').config


it all got errors...

am I doing wrong in somewhere?

btw, I use node v-0.6.12,and the app works fine in local machine.

Chris Matthieu

unread,
Mar 31, 2012, 10:54:35 AM3/31/12
to node...@googlegroups.com
Use dirname as referenced in our FAQs on our help page. http://nodester.com/help.html#faq

Sent from my iPhone

Brecht Huang

unread,
Apr 7, 2012, 5:38:09 AM4/7/12
to node...@googlegroups.com
I made a silly mistake, the config was put in .gitignore, of course the error happend!



chrismatthieu於 2012年3月31日星期六UTC+8下午10時54分35秒寫道:
Reply all
Reply to author
Forward
0 new messages