Skip to content

Instantly share code, notes, and snippets.

@mnylen
Created July 8, 2011 16:31
Show Gist options
  • Save mnylen/1072202 to your computer and use it in GitHub Desktop.
Save mnylen/1072202 to your computer and use it in GitHub Desktop.
express = require 'express'
assetManager = require 'connect-assetmanager'
app = express.createServer
app.use assetManager
var express = require('express'),
assetManager = require('connect-assetmanager');
var app = express.createServer();
app.use(assetManager);
$ coffee app.coffee
TypeError: Object function (options){
if ('object' == typeof options) {
return new HTTPSServer(options, Array.prototype.slice.call(arguments, 1));
} else {
return new HTTPServer(Array.prototype.slice.call(arguments));
}
} has no method 'use'
at Object.<anonymous> (/.../app.coffee:6:7)
at Object.<anonymous> (/.../app.coffee:7:4)
at Module._compile (module.js:402:26)
at Object.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script.js:62:19)
at /usr/local/lib/node_modules/coffee-script/lib/command.js:120:29
at /usr/local/lib/node_modules/coffee-script/lib/command.js:90:26
at [object Object].<anonymous> (fs.js:107:5)
at [object Object].emit (events.js:61:17)
at afterRead (fs.js:878:12)
at wrapper (fs.js:245:17)
$ node app.js
(no errors)
@mnylen
Copy link
Author

mnylen commented Jul 19, 2011

So the problem was that the CoffeeScript was translated to:

 var app = express.createServer;
 app.use(assetManager);

And of course it wouldn't work, because app was the createServer function, not it's return value. To fix: add parenthesis after createServer (and any other method call that doesn't have any parameters, because CoffeeScript compiler can't determine what you want then)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment