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, because alt
module is on node_modules
directory
import CustomiserActions from 'js/actions/Customiser.actions.js';
- It doesn't work, because js
module is in client
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 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.