PHPStorm does not recognise JS library methods even after adding the library in settings
I recently updated my PHPStorm to 2017.3.4 and updated all the libraries in Language Frameworks > JavaScript > Libraries to use the scoped npm equivalents (like: @types/jasmine, @types/react, @types/webpack). However, now methods from any of those libraries are not recognised. Am I missing any configuration? I tried to follow old posts regarding similar problems but they didn't seem to help.
Please sign in to leave a comment.
please try invalidating caches (File | Invalidate caches, Invalidate and restart) - does it help?
If not, please provide code snippets where the methods are not resolved plus a screenshot of your Javascript libraries settings (Settings | Languages & Frameworks | JavaScript | Libraries).
BTW, how did you update the libraries? what did you do exactly?
Invalidating the caches didn't work.
To update the libraries I simply removed the old ones and then downloaded the new ones. Below is how it currently looks:
In the code snippet below you can see that describe, it, expect and toBe are all not recognised:
Please let me know if you need more information.
Having a single `@types/jasmine` library is enough to get all these types resolved; try disabling all other libraries (`karma`, `karma-jasmine`, etc.) - does it help?
No, it didn't change anything. I also tried to invalidate the caches again but nothing changed. Any other suggestions? Is there anything that could cause the @types to be ignored? Do I need to install anything on my project?
No, no need to install anything.
Are the libraries really there? Select your `@types/jasmine` library and press Edit - what can you see?
Also, can you check if you can recreate the issue in a new project?
When I press Edit I see this:
Shouldn't there be more information?
I have 3 projects with the same setup. They all have this same issue.
hmm.. do you have `javascript\extLibs\global-types\node_modules\@types\jasmine\index.d.ts` file in PhpStorm configuration directory (https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs) ?
Also, can you share a project that can be used to recreate the issue?
yes, the `javascript\extLibs\global-types\node_modules\@types\jasmine\index.d.ts` file is present.
How can I share a project?
please upload it to some file server and provide a link
Here is a very basic project: https://github.com/bensampaio/phpstorm-example. When I open this project on my PHPStorm the jasmine methods in `index.spec.js` are not recognised.
works fine for me using your project (PhpStorm 2017.3.4):
I'd suggest removing PhpStorm caches, plugins and preferences and re-downloading the libraries:
I closed my PhpStorm, removed all the folders you mentioned, reopened it and reinstalled @types/jasmine but nothing changed :(
I do see a difference between my PhpStorm and yours, though. My External Libraries > @types is empty even though @types/jasmine is installed and enabled.
I am using Node 9.5.0 and yarn 1.3.2. Could this be related? My PhpStorm is configured to use node and yarn. However, I also tried to change to npm and reinstall @types/jasmine but the problem remains.
Weird... Please can you provide your idea.log (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files)? You can push it to github, for example
I just noticed that copy pasting the `rm` commands was not working because of the apostrophes. I tried again and this time it worked. Thanks a lot!
I found out the origin of the problem. In Settings | Editor | File Types I had node_modules in the list of ignored files and folders.