[英]Redis in Nodejs on Cloud9 IDE: [Error: Auth error: undefined]
[英]flatironjs and Cloud9; window is undefined error?
还有其他人使用带有Cloud9 ide的flatironjs吗?
在我的server.js文件中,我有:
require("coffee-script");
var app = require("./app");
app.listen(process.env.PORT);
然后在我的app.coffee文件中,我有:
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"
当我尝试在Cloud9 IDE中运行它时,我得到以下内容:
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)
如果我在不使用flatiron的情况下创建一个标准的http服务器,一切都很棒:
http = require "http"
module.exports = http.createServer (req, res) ->
res.writeHead 200, {'Content-Type': 'text/plain'}
res.end "Hello World\n"
思考?
所以在eventemitter2.js文件的底部有一些代码基本上试图“同构”并且在node.js和浏览器中都有效。 它试图通过测试定义的以下全局变量来猜测哪个环境:
如果定义了所有这些,则eventemitter2会将其导出的属性附加到exports
对象以在node.js中使用。 否则,它会将它们附加到window
对象以便在浏览器中使用。
由于某些原因,在cloud9中,没有定义这3个全局变量中的1个或更多个,并且假设window
存在且失败,它将分支到“浏览器”模式。 我对cloud9 ide托管环境知之甚少,无法准确理解它们中的哪一个(或2个或3个)以及它为什么缺失。
你的vanilla http
代码可以工作,因为它不会加载eventemitter2,当你使用flatiron时会加载它,这取决于broadway,它依赖于eventemitter2。
这是在Solaris上运行的EventEmitter中的错误。 如果您只是在最新版本的Solaris上运行应用程序,您也可以看到它,并将使用相同的错误消息崩溃。 您可以使用修补后的EventEmitter2来删除对浏览器的检查。
我为你创造了一个问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.