Add es6 import on code completion not working for npm node_modules even though unexcluded

Hello, I am having trouble getting intellij idea to code complete and automatically add import statements to my javascript module files from es6 module packages installed with npm (specifically the d3.js library). I have the npm packages marked as not excluded and I have turned on unambiguous imports on the fly.

What does work: If I define my own es6 module that exports a function, and then start typing the name of that function in another module in the same project, then idea code completes and adds import statements like import {functionname} from "./...." when I hit enter on autocomplete, exactly as expected.

What doesn't work: When I type the name of a function from an es6 module package installed by npm in node_modules, I don’t get code completion, even though it’s not excluded. But if I type out the function name completely manually, then the function name changes to italics, and if I hit alt-enter, I can select “insert import {select} from "d3-selection";” which adds the import statement correctly. However, I should add that if I do the previous action for a particular function in one js file of a project, and then go to a different js file in the project, now code completion and auto imports works just for that one function (but none others).

Can anyone provide any advice on how to get this to work? Thanks.

Comment actions Permalink

Could you please provide a code sample, package.json and your IDE version?


It works for me with select from 'd3-selection' package:

Comment actions Permalink

Oksana, I starting putting together an example for you in a new idea project, but the problem did not reappear. I copied all my source code into a new folder, opened it up as a new idea project, re-initialized npm, and now everything is working. Still not sure what is wrong with my original project, but for now the issue is resolved for me in the new project. I'll report back if it breaks again. Thanks.


Please sign in to leave a comment.