Typescript: "Cannot find module" with valid typings Typescript: "Cannot find module" with valid typings express express

Typescript: "Cannot find module" with valid typings


Triple-slash directives need to precede any statements in your file. Your "use strict" prologue needs to come after your reference comments as so:

///<reference path="../typings/main.d.ts"/>'use strict';import * as express from "express";

As a follow up to your comment where you're not getting any emit for your import: that's because TypeScript performs import elision. Unless you use the module for some value, the compiler won't emit the import because it assumes you only need that module for its types.


The answer by Daniel is technically correct but based on your tsconfig main.d.ts would have still been picked up so would not fix issues for you.

That said I did find issues and sent a pull request: https://github.com/jereynolds/ts-test/pull/1


  • You probably should exclude typings and node_modules otherwise the compile will contain duplicate identifiers (typings) / will be slow (node_modules)

  • typings install serve-static (needed for express) and mime (needed for serve-static).


I know this is an old question, and sorry for bumping it but it comes up as one of the first links in Google.

Since the above didn't fix my issue and I eventually resolved it, I thought I'd share... In my case, it was relative pathing that caused the issue.

My typings were in

typings/bootstrap, typings/react-dom, typings/react, etc.

The react-dom one has an import from 'react'. To fix my code I had to edit it to be '../react/react'. Simple!