I'm trying to use Javascript ES6 import syntax with WebPack configured to use client
and node_modules
as root paths for resolving imports.
IntelliJ Idea discovers modules from "node_modules" directory, but it cannot resolve paths from "client" directory.
For example:
When im using:
import ImmutableStore from 'alt/utils/ImmutableUtil';
- IntelliJ finds proper paths, becausealt
module is onnode_modules
directoryimport CustomiserActions from 'js/actions/Customiser.actions.js';
- It doesn't work, becausejs
module is inclient
directory.
I've tried many options in module settings/project settings/marking directory as source roots/adding external libraries but nothing seems to work.
IntelliJ Idea version: 14.1.5
I'm trying to use Javascript ES6 import syntax with WebPack configured to use client
and node_modules
as root paths for resolving imports.
IntelliJ Idea discovers modules from "node_modules" directory, but it cannot resolve paths from "client" directory.
For example:
When im using:
import ImmutableStore from 'alt/utils/ImmutableUtil';
- IntelliJ finds proper paths, becausealt
module is onnode_modules
directoryimport CustomiserActions from 'js/actions/Customiser.actions.js';
- It doesn't work, becausejs
module is inclient
directory.
I've tried many options in module settings/project settings/marking directory as source roots/adding external libraries but nothing seems to work.
IntelliJ Idea version: 14.1.5
Share Improve this question edited Oct 14, 2015 at 15:01 Bergi 665k161 gold badges1k silver badges1.5k bronze badges asked Oct 14, 2015 at 14:37 kazkaz 1,9431 gold badge13 silver badges19 bronze badges 1- The issue is that IntelliJ does not have a proper support to webpack, check this question stackoverflow.com/questions/31164331/…, they are actively development this feature to the next version of Webstorm, i guess that in a next version of intellj this going to be included. – Jesús Quintana Commented Oct 28, 2015 at 9:48
4 Answers
Reset to default 7I know this is old thread. Just for reference, mark the parent directory(in this case 'js') as 'Resource Root,' then Intellisense will work on 2016 version.
What worked for me:
File > Invalidate Caches / Restart...
Based on my own experience, IntelliJ will by default search for the source file in the node_modules
directory unless it's a relative path like this:
import CustomiserActions from './js/actions/Customiser.actions.js';
Depending on how your project is structured/build, this might be a solution to your problem.
In my case I had a Javascript project and *.js files was not recognized as a javascript file (Note the icon with JS) but rather as a text file.
IntelliJ -> Preferences... -> Editor -> File Types
Make sure *.js extension is listed under JavaScript and absent for Text file types