Alex K
Alex K

Reputation: 5212

How can I fix "cannot find declaration to go to" in WebStorm?

I'm using WebStorm with JavaScript and when I press F3 or Ctrl + Click on function I get message that say "cannot find declaration to go to". This happens only in functions that I wrote on my computer, with other functions it works great.

I wrote my functions declarations exactly like all the other functions that go to declaration works for them. I'm using Ultimate version.

I tried File->Invalidate cache\Restart... and it didn't work.

Any suggestions?

EDIT: Example of the function:

    FaasInitUtils.prototype.createCompnentData = function createCompnentData(app) {

}

when I call this function I do it like this:

        FaasInitUtils.prototype.configureSiteCdmRT = function configureSiteCdmRT() {
var componentData = this.createCompnentData(app);
}

Upvotes: 3

Views: 12959

Answers (5)

naval Hurpade
naval Hurpade

Reputation: 11

I fixed it by deleting .idea folder from project

Upvotes: 0

vincenthavinh
vincenthavinh

Reputation: 462

  1. Right-click on the closest src/ folder from the file you want to navigate from.
  2. Select Mark Directory as
  3. Select Sources Root

This problem happens if for example you have a repo where you have a frontend folder and inside you have multiple apps where each one has a src/ folder.
Then PyCharm/WebStorm takes your root folder (or maybe the first src/ folder cascading from the root folder) as the root path for your imports relative paths.
Which is not the good root path for your frontend app imports because of the nesting.
So when you try to navigate to a function declaration, PyCharm/WebStorm cannot find the location starting from the root folder (and not your frontend app folder)

Upvotes: 2

stefan
stefan

Reputation: 2785

Long shot: I had the same problem. For some reason in Preferences -> File Types -> JavaScript : there wasn't any pattern matching *.js files. I added *.js and then it worked. Cheers

Upvotes: 3

Denis Golubev
Denis Golubev

Reputation: 101

My case:

  • go to WebStorm Default IDE directories (C:\Users\JohnS\AppData\Roaming\JetBrains)

  • delete all files in this folder

  • reopen WebStorm

WARNING: But after these steps your JetBrains products configuration will be reset. So u can try to delete this folder WebStorm2020.1 (the name depends on WebStorm version) first and try is this will solve the problem, if not do my steps.

These steps fix for me this bug. This article helps me to find Default IDE directories for my OS: https://www.jetbrains.com/help/webstorm/tuning-the-ide.html#default-dirs

Upvotes: 2

Alex K
Alex K

Reputation: 5212

I manged to fix it. I had a lot of projects and big one in Webstorm, what I excluded target folders and then everything started to work (including colors). So I think that there is a problem with the configuration of memory limitation/consumption.

Upvotes: 2

Related Questions