Enyo 1.0 & Node.js

edited March 2012 in Enyo 1.0
Hi,

I have had success loading the enyo 1.0 library with an apache2 server. However, when I try to load my stuff on a node.js server, I get
1Uncaught SyntaxError: Unexpected token <
in enyo.js (line 1)

The way the page is served is via the example in socket.io's web site:
function handler (req, res) {
  fs.readFile(__dirname + '/index.html',
  function (err, data) {
    if (err) {
      res.writeHead(500);
      return res.end('Error loading index.html');
    }

    res.writeHead(200);
    res.end(data);
  });
}
And then in index.html I have in the head:


(It is finding the enyo.js file, as evidenced by that error).

Any suggestions?

Comments

  • What do you get if you use curl to request that enyo.js file from your node server? It seems like it's returning your index.html page instead of the enyo.js file.
  • can you give an example of the curl line?
  • When I do
    curl ipaddress:port
    I just get the index.html file

    curl ipaddress:port/1.0/framework/enyo.js

    Also yields the index.html file.
  • Also, that explains why when I pull up the Chrome console, it shows the index.html stuff in the "enyo.js" debug screen.
  • Yeah, you need something in your curl server code that handles the GET request and turns it into a file send. Are you using express or some other framework for this?
  • Honestly, I'm pretty new at this. I was using node.js as just a socket.io connection with apache2 hosting my site. That was kinda problematic, so I'm trying to do this all node.js approach.

    It sounds like the issue is with the httpServer handler, though. I guess any data it receives, it then tries to just send index.html, whereas it should be serving the file it is asking for.

    This was without the "express" framework.
  • You can also just load the enyo script files from another server. Just have the tags get them from a separate server that has them like http://enyojs.com/enyo-1.0/enyo.js
  • Right. I'm getting somewhere. I modified the httpServer function and am now seeing the other .js functions instead of index.html. Not quite working, but there's hope. :)
  • edited March 2012
    Uncaught TypeError: Cannot read property 'windows' of undefined
    enyo.windows.manager.getWindows enyo-build.js:6220
    enyo.windows.getWindows enyo-build.js:6053
    enyo.windows.ensureUniqueWindowName enyo-build.js:5994
    enyo.windows.finishOpenWindow enyo-build.js:5991
    (anonymous function) enyo-build.js:6309
    enyo.requiresWindow enyo-build.js:5766
    (anonymous function)
    Any suggestion on that one?
  • 1) use the <pre> tag around multiline <code> sections to get proper formatting. I've been fixing your posts up.

    2) The crash seems to be because the global "enyo" object isn't defined on the window that enyo.getRootWindow() returns. What browser environment are you running this in? It could be that the code in getRootWindow is detecting something else. Do you have any globals named "opener", "rootWindow" or "top"?
  • I'm using Chrome / Ubuntu 11.10. By the way, I changed my port back to 80 [originally I was on another one], and now I'm seeing enyo things.
Sign In or Register to comment.