I'm having another issue with node.js, this time I cannot get my javascript code to recognize that a coffeescript module's class has functions.
In my main file, main.js I have the following code:
require('./node_modules/coffee-script/lib/coffee-script/coffee-script');
var Utils = require('./test');
console.log(typeof Utils);
console.log(Utils);
console.log(typeof Utils.myFunction);
And in my module, test.coffe, I have the following code:
class MyModule
myFunction : () ->
console.log("debugging hello world!")
module.exports = MyModule
Here is the output when I run node main.js
:
function
[Function: MyModule]
undefined
My question is, why is my main file loading the correct module, but why is it unable to access the function? What am I doing wrong, whether it be with the coffeescript syntax, or with how I am requiring my module? Let me know if I should clarify my question.
Thanks,
Vineet
require('coffee-script');
rather than using a full path. Stuff in node_modules is automatically picked up automatically. – sakkaku Jul 18 at 17:24