TS cannot find modules

TypeScript relies on definition files that define the types, interfaces, etc. for libraries. I'm not familiar with FountainJS, but I'm guessing it's smart enough to create a typings.json file in your workspace. If so, all you need to do is install typings (npm install typings --global) and then use it to install the definitions by doing typings install.

If they didn't include typings.json (though I can't imagine they wouldn't), follow the instructions on their README to search for and install definitions for the dependencies.

I generally add the following lines to package.json so that the typings will be installed automatically any time you run npm install

"scripts": { "postinstall": "npm run typings", "typings": "typings install", }

If you're not familiar with TypeScript, I recommend going through their basic tutorial to get you started: https://www.typescriptlang.org/docs/tutorial.html.


̶R̶e̶m̶o̶v̶i̶n̶g̶ ̶"̶m̶o̶d̶u̶l̶e̶"̶ ̶a̶n̶d̶ ̶"̶t̶a̶r̶g̶e̶t̶"̶ ̶f̶i̶e̶l̶d̶s̶ ̶f̶r̶o̶m̶ ̶̶t̶s̶c̶o̶n̶f̶i̶g̶.̶j̶s̶o̶n̶̶ ̶w̶o̶r̶k̶e̶d̶ ̶f̶o̶r̶ ̶m̶e̶.̶

Update: removing target is ok, but removing module is not an option as the compiler depends on it. You can also solve the problem by adding "moduleResolution": "node" to the tsconfig.

Tags:

Typescript