Webstorm 无法识别 JavaScript 文件 [英] Webstorm not recognising JavaScript file

查看:81
本文介绍了Webstorm 无法识别 JavaScript 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Webstorm 无法将我的其中一个 .js 文件识别为 JavaScript 文件,因此我失去了语法高亮显示并且无法添加断点.我查看了 workspace.xml 文件,有问题的文件似乎与其他正常工作的 .js 文件具有相似的设置.

Webstorm doesn't recognize one of my .js files as a JavaScript file so I'm losing syntax highlighting and being able to add break points. I've looked in the workspace.xml file and the file in question seems to have similar settings to other .js files that work correctly.

如果我更改文件名,它就可以正常工作.所以不知何故,Webstorm 被困在误解具有此名称的文件的类型上.我还可以在哪里编辑项目?

If I change the name of the file it works ok. So somehow Webstorm is stuck on misinterpreting the type of a file that has this name. Where else can I edit the project?

推荐答案

所以我看到了问题的三个可能原因:

So I see three possible reasons for the problem:

  1. 文件被标记为纯文本"

  1. The file was marked as 'Plain text'

存在与此文件匹配的文本文件"文件类型模式(或返回:文件类型JavaScript"排除此文件名).见下图

There is a pattern for 'Text files' file type that matches this file (or back: file type 'JavaScript' exclude this file name). See image below

  1. 有一个自定义插件可以覆盖具有此名称的文件的默认行为(不太可能)

更新:几年后,我找到了导致这种行为的另一个原因,而且很可能是问题的主要根源.当您创建没有任何扩展名的文件时,注册新文件类型关联"出现.您可能会意外地为某些文件名指定新的文件类型.它可以通过 (2) 修复,但这是在那里添加模式的原因.

Updated: after several years I've found one more reason for the behavior and most likely it the main source of the issues. When you create a file without any extensions the "Register New File Type Association" is appeared. And you can accidentally specify a new file type, for some file name. It is can be fixed with (2) but it is the reason why the pattern was added there.

注意:该解决方案适用于所有基于 IDEA 的 IDE:IntelliJ IDEA、WebStorm、RubyMine、PyCharm、PhpStorm.

Note: the solution works for all IDEA-based IDEs: IntelliJ IDEA, WebStorm, RubyMine, PyCharm, PhpStorm.

这篇关于Webstorm 无法识别 JavaScript 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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