关于“标记之后的标识符”的JsHint抛出错误 [英] JsHint throwing error regarding "Identifier expected after token"

查看:243
本文介绍了关于“标记之后的标识符”的JsHint抛出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用node.js和socket.io创建了一个小型聊天应用程序。这对我来说很正常,但是我的编辑器(Eclipse)插件JsHint在我的代码中显示了一个错误,如下所示。

  io.sockets.in(room).emit(msgtype,data); 

错误:

 code>令牌上的语法错误。,此令牌后面的标识符

上面的代码是对我来说运行得很好,但编辑显示错误。我不明白是什么问题,我有谷歌的同样的错误,但仍然没有得到任何解决方案。如果有人告诉我如何在node.js中编写代码,那对我来说非常有帮助。



谢谢,

解决方案

你确定问题来自JSHint吗?我在Eclipse中有完全相同的问题,我也安装了JSHint插件(错误地)假设JSHint警告这个。我试过es5:真的等等,没有任何工作。然后我意识到JSHint没有显示这个错误。当您查看问题选项卡时,可能会在错误后看到类似JavaScript问题的内容,在这种情况下,JSDT验证(仅适用于es3)正在运行而不是JSHint,这是nodeclipse将默认为远据我所知,如果安装。我遇到了很大的问题,禁用它,试图在Window-Preferences中暂停验证,甚至没有。最后,我编辑了.project文件,并从中删除了包含行的所有jsdt,例如



org.eclipse.wst.jsdt.core.jsNature

再次启动eclipse后,错误消失了,我通过选择应该处理的文件激活了JSHint,并且在问题选项卡中有JSHint问题,它正确地不要再提醒我有关sockets的有效使用了。



希望这有助于任何人进行同样的操作!


I have created one small chatting app using node.js and socket.io. It is working fine for me, but my editor's (Eclipse) plug-in JsHint showing me one error in my code as follows.

io.sockets.in(room).emit(msgtype, data);

Error:

Syntax error on token ".", Identifier expected after this token

above code is running very well for me, but editor showing me error. I don't understand what is the problem, I have google for same error, but still not getting any solution. If someone show me how to write code in node.js, that is very helpful to me.

thanks,

解决方案

Are you sure the problem is coming from JSHint? I had the exact same issue in Eclipse, I also had installed the JSHint plugin so (wrongly) assumed JSHint was warning about this. I tried es5:true etc. and nothing worked. Then I realized that JSHint was not showing this error. When you look at "Problems" tab you may see something like "Javascript Problem" after the errors, in which case it is the JSDT validation (only available as es3) is running rather than JSHint, which is what nodeclipse will default to as far as I understand, if installed. I had big problems disabling it, trying to "suspend validation" in Window-Preferences and whatnot. Finally, I edited the .project file as well and removed all "jsdt" containing lines from there like i.e.

org.eclipse.wst.jsdt.core.jsNature

After starting eclipse again, the error was gone, and I activated JSHint by selecting the files it should process and voila, I got "JSHint Problem" in Problems tab and it correctly did not warn me about the valid use of sockets.in any longer.

Hope this helps anybody going through the same!

这篇关于关于“标记之后的标识符”的JsHint抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆