Nodejs 'require' Loading Library In Coffeescript, Empty Object In Javascript
I've come across an interesting problem in NodeJS that pops up now and then at work, and I haven't been able to figure it out. I've written a back-end in CoffeeScript, which I the
Solution 1:
Although the exact reason for the randomness of the behaviour eludes me to this day, I have found that it is related to these libraries being written in CoffeeScript.
It seems that depending on the load order, occasionally third party libraries would register coffee script and my own libraries would load correctly, whereas other times these libraries would load after my own libraries had loaded, resulting in an inability to load coffeescript. Therefore, the solution turned out to be fairly straightforward - register coffeescript. This can be done by putting the following at the start of the node.js app:
require('coffee-script/register')
Refer to the documentation for further information.
Post a Comment for "Nodejs 'require' Loading Library In Coffeescript, Empty Object In Javascript"