Tushar Tushar - 1 month ago 20
TypeScript Question

WebStorm can not find module after installing TypeScript community stubs

I am trying to use a library

ramda
and have installed its TypeScript community stubs in WebStorm —

Ramda Stub

but I am still getting the following error —

Cannot find module 'ramda'.


Error message

I know I can solve this problem using the typings module but then what's the point of installing the stubs via WebStorm then?

Answer

Libraries configured in Settings | Languages & Frameworks | JavaScript | Libraries are only used by WebStorm for code completion/navigation, but they aren't available to TypeScript compiler. When you download Typescript stubs via Settings | Languages & Frameworks | JavaScript | Libraries, they are placed in <webStorm configuration directory>/javascript/extLibs/. It's perfectly fine for WebStorm - it doesn't require placing library files directly in the project folder, as the main purpose of libraries is the ability to use external files for code completion without polluting the project folder. But the tsc compiler does need the d.ts files being placed somewhere in the project directory and referenced via ///<reference> comments/import statements. So, to get downloaded stubs available to typescript compiler, you need to copy/move them to you project directory (and probably rename to more human readable names :)) They will be available to both WebStorm and compiler then. We plan to provide an option to download files directly to the project folder (instead of system/extLibs/ ) in the future versions - see WEB-9237 and linked tickets.