claudioc / jingo

Node.js based Wiki
MIT License
1.02k stars 184 forks source link

get illegal token error #210

Open hajika opened 7 years ago

hajika commented 7 years ago

I suddenly get this error when opening jingo:

SyntaxError: Unexpected token ILLEGAL
    at Function (native)
    at wrap (/home/user/jingo/node_modules/pug/node_modules/pug-runtime/wrap.js:8:30)
    at Object.exports.compile (/home/user/jingo/node_modules/pug/lib/index.js:263:7)
    at handleTemplateCache (/home/user/jingo/node_modules/pug/lib/index.js:216:25)
    at Object.exports.renderFile (/home/user/jingo/node_modules/pug/lib/index.js:418:10)
    at Object.exports.renderFile (/home/user/jingo/node_modules/pug/lib/index.js:408:21)
    at View.exports.__express [as engine] (/home/user/jingo/node_modules/pug/lib/index.js:455:11)
    at View.render (/home/user/jingo/node_modules/express/lib/view.js:128:8)
    at tryRender (/home/user/jingo/node_modules/express/lib/application.js:640:10)
    at EventEmitter.render (/home/user/jingo/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/home/user/jingo/node_modules/express/lib/response.js:966:7)
    at ServerResponse.res.render (/home/user/jingo/node_modules/express-flash/lib/express-flash.js:29:16)
    at /home/user/jingo/lib/app.js:199:9
    at Layer.handle_error (/home/user/jingo/node_modules/express/lib/router/layer.js:71:5)
    at trim_prefix (/home/user/jingo/node_modules/express/lib/router/index.js:315:13)
    at /home/user/jingo/node_modules/express/lib/router/index.js:284:7

I already completely reinstalled jingo and created a new repo, but the error is still there. I cant imagine why?! As far as I know, that can happen when there is an invisible character in JS code, but how suddenly and why its not working after reinstallation?

claudioc commented 7 years ago

@hajika ouch, this sounds bad. Can you give me a bit more details? When is that you get that? On starting jingo, on loading the first page or somewhere else?

thanks!

hajika commented 7 years ago

I get this on opening any page. I checked the wrap.js in the meantime, and it actually complains about the last + (that is the sign in wrap.js:8:30). When I remove the last two +, it will complain about the other plus. Strange.

var runtime = require('./');

module.exports = wrap;
function wrap(template, templateName) {
  templateName = templateName || 'template';
  return Function('pug',
    template + '\n' +
    'return ' + templateName + ';'
  )(runtime); 
}

It might be because of the template variable, I put it in a console.log() and got a very long output with actual code, I guess thats not intended? What should be in the template var? I will attach the output here to give you a hint (everything between the xxx):

jingolog.txt

claudioc commented 7 years ago

Thanks, but this is still not enough: can you please send me also your config.yaml? What is your server (or workstation) configuration? Windows maybe?

hajika commented 7 years ago

CentOs 6

As I said, I completely reinstalled the whole thing, in the config.yaml I only changed the port and the repository path, anything else is like in the default. I also initiated a new git repo.

hajika commented 7 years ago

So I still encounter that problem with the master branch, but not with the v1.7.3, so I hope this will vanish with the next release :)

claudioc commented 7 years ago

It must have something to do with the 1.8.0 release, then (there were big changes there), but I cannot reproduce it on OSX and Ubuntu at the moment.

One of the templates is probably broken somehow but I can't understand where the problem is.

claudioc commented 7 years ago

In the meanwhile try the current version (1.8.1)

claudioc commented 7 years ago

Can you also please tell me you node js version?

hajika commented 7 years ago

I just tried the v1.8.2 and the error appears again. Node version is v0.12.9, but I can change I easily if there is any benefit in it..

claudioc commented 7 years ago

I am pretty sure Node 0.x is not supported anymore, or not supported very well at least.

Please use any of the LTS (since you are updating, go for 6.x)

Thanks