Re: ReferenceError: module is not defined

139 views
Skip to first unread message

Anatoliy C.

unread,
Jan 20, 2013, 12:10:31 PM1/20/13
to compo...@googlegroups.com, RailwayJS
This problem related to running code in another context which have no idea about modules available in your context. To avoid this problem previously we used some hacks with require method. But in compound all hacks were eliminated and I strongly recommend to use '--noeval' flag when generating application and controllers, which allows to solve issues in natural way (without running in new context and related issues). But if you still want to use eval controllers, you could require('nlogger') somewhere else (outside of controllers), for example in config/environment.js:

compound.nlogger = require('nlogger');


and then use in controller as:

compound.nlogger.doSmth()

this hack works, but it's not recommended.

On Sunday, January 20, 2013 11:57:02 AM UTC+7, Rishabh Mahajan wrote:
Was this problem addressed?

My problem is that I want to use the nlogger package for logging and it requires the module to be available where its being called.
I am trying to use it in the controller file.

var nlogger = require('nlogger').logger(module);

nlogger
.debug('>>> DEBUG >>>');

I am getting the same error.
Is there any alternative to this so that I can use packages like nlogger or underscore ?

Thanks
Rishabh Mahajan


On Wednesday, December 14, 2011 2:39:26 AM UTC+9, Jason Palmer wrote:
Hi everyone,

I seem to be having a consistent issue with RailwayJS and I would like
to get some feedback from the community regarding how to fix this,
best practices, etc.

I used the following guideline for defining my application
dependencies:
http://blog.nodejitsu.com/package-dependencies-done-right

And now I'm able to properly install all dependencies locally using
"npm -l install".  GREAT!

However, when I run the server "rw s 8888" I ALWAYS get the following
error:

ReferenceError: module is not defined

This is triggered in my db/schema.js file.  What would cause this?
How can I go about fixing this properly?

I have been searching Google for a while now and am not coming across
anything relevant.  Any help would be much appreciated - I really want
to fully understand what's going on here.

Hopefully relevant information (if you need more please ask):

Railway 0.1.8
NodeJS 0.4.1

OS: OSX Lion

Reply all
Reply to author
Forward
0 new messages