Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

flatironjs and Cloud9; window is undefined error?

flatironjs and Cloud9; window is undefined error?

Problem

Anyone else having luck using flatironjs with the Cloud9 ide?

In my server.js file I have:

require("coffee-script"); 
var app = require("./app");

app.listen(process.env.PORT);

Then in my app.coffee file I have:

flatiron = require "flatiron"
director = require "director"

app = flatiron.app
app.use flatiron.plugins.http

module.exports = app.router.get "/", ->
res.writeHead 200, { "Content-Type": "text/plain" }
res.end "Hello world!\n"

When I attempt to run this in the Cloud9 IDE I get the following:

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        **^ ReferenceError: window is not defined**
    at Object. (/node_modules/flatiron/node_modules/broadway/node_modules/eventemitter2/lib/eventemitter2.js:547:63)
    at Module._compile (module.js:411:26)
    at Object..js (module.js:417:10)
    at Module.load (module.js:343:31)
    at Function._load (module.js:302:12)
    at require (module.js:355:19)
    at Object. (/node_modules/flatiron/node_modules/broadway/lib/broadway/app.js:11:14)
    at Module._compile (module.js:411:26)
    at Object..js (module.js:417:10)
    at Module.load (module.js:343:31)

If I create a standard http server without using flatiron everything runs great:

http = require "http"
module.exports = http.createServer (req, res) ->
res.writeHead 200, {'Content-Type': 'text/plain'}
res.end "Hello World\n"

Thoughts?

Problem courtesy of: Jason

Solution

This is a bug in EventEmitter running on Solaris. You can see it as well if you just run an app on the latest version of Solaris, will crash with the same Error message. You can use the patched EventEmitter2 that removes the check for the browser.

I created an issue for you.

Solution courtesy of: Jan Jongboom

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

flatironjs and Cloud9; window is undefined error?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×