Alon Alon - 5 days ago 4x
TypeScript Question

TS2307: Cannot find module '~express/lib/express'

I'm converting a working JavaScript file to TypeScript.

I use Express in this file, so I've added the following to the top of the file:

///<reference path="./typings/globals/node/index.d.ts" />

import {Request} from "~express/lib/express";

But the second line produces an error:

TS2307: Cannot fine module '~express/lib/express'

I've installed the typings of express, so I actually didn't wrote those two lines by myself, but WebStorm auto generated them by clicking "alt + enter", so I would expect it to work. Unfortunately I get that error.

What am I doing wrong?


The problem was that the script reference path was to "node" rather than to "express":

///<reference path="./typings/globals/node/index.d.ts" />

So this has fixed it:

///<reference path="./typings/modules/express/index.d.ts" />