One .js file not recognized as javascipt, others ok

Hi, I'm actually using IntelliJ to edit my javascript files, but you guys might have a better idea what is going on.

My IntelliJ is having trouble recognizing the file "RowLabel.js" as a javascript file. When I create this file, it treats it as a plain text file (text file icon), and there is no syntax highlighting. If I rename this file, either via the OS or through Refactor -> Rename menu to something else, say "RowLabel2.js", it gets correctly recognized as a javascript file (with syntax highlighting). I am unable to duplicate this behavior with any other file name, except that particular one. Weird, huh?

Attached is a screen cap showing this problem. Here, I've made a new project "untitled" with "RowLabel.js" and "RowLabel2.js" files, that are both empty. I'm using the latest version of IntelliJ.

I have tried invalidating my caches already. Is there anything else I can try?


Comment actions Permalink

Hi Timothy,

Settings | File Types | Text files -- check for "RowLabel.js" pattern there and remove it.

Comment actions Permalink

Thanks, that was exactly it!
So perhaps you can also tell me how it ended up there?

Comment actions Permalink

To answer my own question, I must have used the new file dialog, and associated RowLabel.js as a text file type. Thanks for your helpful reply, Andryi!

Comment actions Permalink

I do not know for sure .. but it is indeed most likely to be the reason.

Comment actions Permalink

I did something similar by mistake :

  • Created new file
  • Entered filename without extension
  • Got prompted by the new file dialog
  • Selected Open matching files in associated application
  • Pressed OK

This prevented me from editing this specific file in PhpStorm. Note that deleting the file and recreating it didn't solve the issue; it looked like the filename was the problem.

After a while I found out that a pattern entry had been added in Settings | File Types | Files Opened In Associated Applications, with this specific filename. Make sure you remove it from there too.

Hope that helps anyone encountering this issue.

Comment actions Permalink
Thank you Nicolas Beaucage, you're the master
Comment actions Permalink

I have the same issue, but not the same cause or maybe just a newer IntelliJ that doesn't offer the same fix?

Just like the original post:

I was adding a file and somehow types got in the mix, though I named my file foo.js

The file was added to git as well.

It is recognized as a Text File and no syntax highlighting, no auto-complete or formatting.

If I rename the file just like the original poster (with a 2) it is recognized as JS and I get the benefits of an IDE.

Unlike the "accepted" fix this file, under the original name (foo.js) is not listed in the File Types dialog under Text.


Comment actions Permalink

I just want to note that I have:

git rm -f foo*

But, same thing when I create a new file.

So, I followed the rm op with a commit.

Same behaviour...

Comment actions Permalink

Hello Neil Lindberg,

I know it might seem a bit tedious, but I would recommend browsing all options in the Preferences | Editor | File Types | Recognized File Types list.

Ensure that the foo.js filename is not present in any Registered Patterns down below. For good measure, ensure it's not in Ignore files and folders further below either.

Hope that helps, have a nice day!

P.S. I'm using PhpStorm 2017.3.4


Comment actions Permalink

@Neil Lindberg 

Please provide screenshots -- e.g. how that file looks in Project View panel. In particular I'm interested in file icon.

Use it using Default theme and not some Material or stuff where icons may be replaced by others/unknown to me.

Comment actions Permalink

I did find it in the File Types under Text. I was looking through all the types expecting *.foo.js or *.js in the text list. After clearing all refs from .idea/workspace.xml and restarting I enlisted help and found the file name at the bottom of the list.

So, it was me. Thanks. I don't know how to delete my comments or I would.

Comment actions Permalink

I LOVE you @Andriy Bazanov! Thanks, this had me suck for a while.

Comment actions Permalink

For others stumbling across this, I have an extensionless project all interpreted as PHP (don't ask.) Adding * to the PHP file types list fixes that and allows all the IDE features to work, but breaks all the features for JS - all black type, no navigation, etc. etc. Posting another thread about it.


Please sign in to leave a comment.