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).