Importing node-modules with TypeScript

TypeScript needs to know that http is present.

Updated

Install the type definitinos for node:

npm install @types/node

Old answer

Follows these two steps

  • Download the node.d.ts file from here : https://github.com/borisyankov/DefinitelyTyped/tree/master/node
  • At the top of your file add:

    /// <reference path="node.d.ts" />
    

PS: See a sample test file : https://github.com/borisyankov/DefinitelyTyped/blob/master/node/node-tests.ts

Leave a Comment