"Cannot resolve symbol" when using ES6 `import` syntax

AndreKR picture AndreKR · Mar 2, 2016 · Viewed 13k times · Source

Here an example is given how to import certain classes from a module:

import {ModalContainer, ModalDialog} from 'react-modal-dialog';

However, PhpStorm (latest EAP) gives me an error:

Cannot resolve symbol 'ModalDialog'

I installed the package with npm install react-modal-dialog and it is present in node_modules.

The equivalent var {ModalContainer, ModalDialog} = require('react-modal-dialog'); works fine.

Answer

jubalm picture jubalm · Nov 6, 2016

I encountered this when setting up a React project and all i did was download the import's typescript definition, in my case just searched for react.

enter image description here

Instructions for adding libraries to your project can be found on webstorm's help page.