如何解释SyntaxError:意外的令牌(?:?),raisedAt :?

时间:2018-11-09 09:19:02

标签: javascript node.js express passport.js

我不记得对我的代码进行任何重大更改,但是突然它停止了工作。专门显示登录屏幕失败。

const express = require('express');
const mysql = require('mysql');
const passport = require('passport');
const router = express.Router();

router.get('/', function(req, res, next) {
    console.log('Login (get)');
    let msg = (req.usrMsg === null && typeof(req.usrMsg) !== "undefined")?req.usrMsg:"";
    console.log('msg:',msg);
    res.render('login', { 
            title: 'Login',
            message: msg
        });
});

控制台日志已打印,但随后我得到:SyntaxError: Unexpected token (141:0) ... raisedAt: 6745 这个特定的文件login.js不含141行,因此我应该考虑查看哪个文件?

错误消息继续这样:

{ SyntaxError: Unexpected token (141:0)
    at Parser.pp.raise (D:\Code\ghdb\node_modules\acorn\dist\acorn.js:943:13)
    at Parser.pp.unexpected (D:\Code\ghdb\node_modules\acorn\dist\acorn.js:1503:8)
    at Parser.pp.parseExprAtom (D:\Code\ghdb\node_modules\acorn\dist\acorn.js:327:12)
    at Parser.pp.parseExprSubscripts (D:\Code\ghdb\node_modules\acorn\dist\acorn.js:216:19)
    at Parser.pp.parseMaybeUnary (D:\Code\ghdb\node_modules\acorn\dist\acorn.js:197:19)
    at Parser.pp.parseExprOps (D:\Code\ghdb\node_modules\acorn\dist\acorn.js:151:19)
    at Parser.pp.parseMaybeConditional (D:\Code\ghdb\node_modules\acorn\dist\acorn.js:133:19)
    at Parser.pp.parseMaybeAssign (D:\Code\ghdb\node_modules\acorn\dist\acorn.js:110:19)
    at Parser.pp.parseExpression (D:\Code\ghdb\node_modules\acorn\dist\acorn.js:86:19)
    at Parser.pp.parseStatement (D:\Code\ghdb\node_modules\acorn\dist\acorn.js:1750:23)
  pos: 6744,
  loc: Position { line: 141, column: 0 },
  raisedAt: 6745 }

我怎样才能真正找到意外的令牌?

谢谢你, 詹斯

0 个答案:

没有答案