Search code examples
node.jsautocompletewebstormjetbrains-ide

JetBrains WebStorm npm modules autocompletion not working


I am new to Node.js development and I have installed WebStorm from JetBrains to use it as my JavaScript IDE.

So I am following a tutorial in Udemy and I have come to notice the following problem.

I installed some modules with npm from WebStorm Console and although my JS script is working as intended, WebStorm autocompletion for the npm modules is not working.

Coding assistance for Node.js in my settings is marked! What do I do wrong?

Image Example


Solution

  • The problems occur because of the weird way properties are defined. For example, in chalk package they are generated dynamically using Object.defineProperty(this, styleName, {value: builder});, where the styleName is a color name you use in your code. There is no way to resolve them when analyzing file statically.

    Normally installing Typescript stubs can be used as a workaround. But this doesn't work for validator due to WEB-43528. chulk typings are included in package distribution, but not resolved because the required fields in package.json are missing. As a workaround, open node_modules/chalk/package.json and add "types": "index.d.ts", to it:

    enter image description here

    this should help:

    enter image description here