Webstorm does not recognize JavaScript file

Look

Webstorm does not recognize one of my .js files as a JavaScript file, so I lose syntax highlighting and can add breakpoints. I looked at the workspace.xml file and this file seems to have similar settings for other .js files that work correctly.

If I change the file name, it will work fine. So for some reason, Webstorm is stuck in misinterpreting the type of file with that name. Where else can I edit a project?

Context menu

+61
intellij-idea file-type webstorm pycharm rubymine
Nov 11 '14 at 18:37
source share
5 answers

So, I see three possible causes of the problem:

1) The file was marked as "Plain Text"

2) There is a “Text Files” file type template that matches this file (or vice versa: the “JavaScript” file type excludes this file name). See image below.

enter image description here

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

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

+151
Nov 12 '14 at 13:24
source share

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

  • Right-click the file.

  • One of the menu options is Mark As Javascript. Just below "Delete."

  • Click this. Now your file is now recognized as a javascript web service.

Since WebStorm did not allow screenshots after right-clicking, therefore, it was not possible to add it here.

+11
Jan 18 '16 at 10:03
source share

File -> Preferences -> Editor -> FileTypes -> Text Files -> check the "ContentRepository.js" template and delete it.

+10
Apr 20 '17 at 8:43
source share

It did the trick for me
1) Preferences
2) Editor
3) FileTypes
4) javascript search
5) Add *.js to registered templates

+1
Apr 6 '18 at 6:24
source share

You can also try "Template Data Languages" (in file> settings) to force the syntax of a specific language to be highlighted for a specific file or folder. See screenshot below. enter image description here

For a block of code, you can also use "language embedding". Just highlight the code block, wait until a small light appears, then select the lower option and the language you need (a screenshot is also attached)

enter image description here

0
Jun 15 '19 at 4:13
source share



All Articles