Webstorm not recognising JavaScript file

2019-01-17 02:35发布

Look

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.

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?

Context menu

4条回答
干净又极端
2楼-- · 2019-01-17 02:47

If the file was marked as "Plain Text", then this can be fixed as follows:

  1. Right click on the file.

  2. One of the menu options is "Mark as Javascript" . Just below "Delete".

  3. Click that. Your file is now recognized as javascript by WebStorm.

Since WebStorm was not allowing screenshots after right click so couldn't add it here.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-01-17 02:50

File -> Settings -> Editor -> FileTypes -> Text files -> check for "ContentRepository.js" pattern there and remove it.

查看更多
淡お忘
4楼-- · 2019-01-17 03:06

So I see three possible reasons of the problem:

1) The file was marked as 'Plain text'

2) 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

enter image description here

3) There is a custom plugin that overrides default behaviour for files with this name (unlikely)

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

查看更多
劫难
5楼-- · 2019-01-17 03:07

For me this did the trick
1) Preferences
2) Editor
3) FileTypes
4) Search for javascript
5) Add *.js to registered patterns

查看更多
登录 后发表回答