Hello Roly, To answer your question the stack trace looks like this:
=========== C:\Users\Yishay\Documents\My Web Sites\Express Site\public\Server.js:1 alert('serving') ^ ReferenceError: alert is not defined at Object.<anonymous> (C:\Users\Yishay\Documents\My Web Sites\Express Site\public\Server.js:1:63) at Module._compile (module.js:446:26) at Object..js (module.js:464:10) at Module.load (module.js:353:31) at Function._load (module.js:311:12) at Array.0 (module.js:484:10) at EventEmitter._tickCallback (node.js:190:38) =========== Regardless of the stack trace 'public/Server.js' shouldn't be evaluated on the server side. It should be served statically to the browser. The problem is that the static file happens to be named 'Server.js'. If I rename the file to 'Server2.js' everything works fine, however I'd rather not do this as 'Server.js' is part of an elaborate 3rd party library. Anyway, I'm looking for a simple configuration that will tell node.js not to treat files named 'server.js' any differently than other files, provided they're under the 'public' folder. Thanks. On Tuesday, August 7, 2012 11:07:44 PM UTC+3, Roly Fentanes wrote: > > That looks like a compile error. What does the stack trace look like? I > doubt the error is coming from server.js > > On Tuesday, August 7, 2012 12:39:28 PM UTC-7, yishayw wrote: >> >> Hi, >> >> I have a site which uses a library with a static file named server.js. >> Node.js seems to be treating this as a file which needs to be interpreted >> on the server side rather than a static file. Hence, I get an error: >> 'Uncaught >> SyntaxError: Unexpected token < ' >> >> Is there any way around this? >> >> I created a small example of the problem with code snippets below. >> >> Thanks in advance, >> Yishay >> >> Here's my server code: >> >> ==== >> >> /** >> * Module dependencies. >> */ >> var express = require('express') >> , routes = require('./routes'); >> var app = module.exports = express.createServer(); >> // Configuration >> >> app.configure(function(){ >> app.set('views', __dirname + '/views'); >> app.set('view engine', 'jade'); >> app.use(express.bodyParser()); >> app.use(express.methodOverride()); >> app.use(app.router); >> app.use(express.static(__dirname + '/public'));}); >> >> app.configure('development', function(){ >> app.use(express.errorHandler({ dumpExceptions: true, showStack: true >> }));}); >> >> app.configure('production', function(){ >> app.use(express.errorHandler());}); >> // Routes >> >> app.get('/', routes.index); >> >> app.listen(process.env.port || 3000); >> console.log("Express server listening on port %d in %s mode", >> app.address().port, app.settings.env); >> >> >> ==== >> >> My index.html (under public/index.html) >> >> ====== >> >> <!DOCTYPE html> >> <html lang="en"> >> <head> >> <meta charset="utf-8" /> >> <title></title> >> </head> >> <body> >> <script src="Server.js"></script> >> hello >> </body></html> >> >> >> ======= >> >> >> And Server.js which is under the same dir >> >> >> ======= >> >> >> alert('serving'); >> >> >> ======= >> >> >> >> -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en