I am pretty new to CoffeeScript. I am trying to create Node.js application using the Express.js framework. And in my express app configuration I have this line of code that is compiling wrong:
app.use express.static path + '/public'
it is compiling to this:
app.use(express["static"](path + '/public'));
when I need to be this:
app.use(express.static(path + '/public'));
Does anyone know why this happening and how to fix this? It is causing my public folder to unaccessible.
I am using CoffeeScript 1.3.1
static
could be a reserved word in future versions of javascript/ecmascript. Just like top
now. So using it as a variable name could cause errors somewhere.
That's why coffee is trying to avoid it.
But they are equivalent, so try to find errors somewhere else.
They're equivalent, don't worry about it.
Express framework using 'serve-static' module for export static method:
exports.static = require('serve-static');
You may try solve your problem like this:
app.use '/static', require('serve-static')(__dirname + '/static')
or override static method in your module.