[英]Invisible mythical unexpected token on unexisting line in Node.js
So today, node don't run my app, because it finds unexpected token at line 219. Here is the full error log: 所以今天节点不运行我的应用程序,因为它在第219行发现了意外的令牌。这是完整的错误日志:
syberic@syberic:~/Web/lotalot$ node app.js
/home/syberic/Web/lotalot/config/passport.js:219
});
^
SyntaxError: Unexpected token )
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/home/syberic/Web/lotalot/app.js:22:1)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:141:18)
at node.js:933:3
BUT the PROBLEM is, the file passport.js
Has 217 lines! 但问题是,文件
passport.js
有217行! Here is a screenshot of how the end of this file looks in VIM: 以下是该文件结尾在VIM中的截图:
I inspected the file with some other text editors, mousepad, gedit, etc. But the file always have 217 lines.
我用其他一些文本编辑器,鼠标垫,gedit等检查了文件。但文件总是有217行。 When i add some empty lines to the end of the file, unexpected token moves down respectively.
当我在文件的末尾添加一些空行时,意外的令牌分别向下移动。 What kind of MAGIC is this?
这是什么样的魔术 ? How can this happen?
怎么会发生这种情况? I'm so damn frustrated.
我太沮丧了。
I think this means you have an extra opening brace in your program. 我认为这意味着你的程序中有一个额外的开口支撑。 Internally, Node pastes the text of your program inside a function, so there are some extra characters before your file contents and an extra line after it.
在内部,Node将程序的文本粘贴到函数中,因此在文件内容之前有一些额外的字符,在它之后有一个额外的行。 I can reproduce this easily with this one-line file that has just an open brace in it:
我可以使用这个只有一个开放式括号的单行文件轻松地重现这个:
$ cat foo.js
{
$ node foo.js
/Users/dap/foo.js:3
});
^
SyntaxError: Unexpected token )
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
I would suggest using a tool like javascriptlint to find the extra open brace. 我建议使用像javascriptlint这样的工具来找到额外的开放式支撑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.