Typescript - Cannot find 'http' module in Visual Studio Code

I am using Visual Studio code to develop NodeJS and Typescript. If I write this code:

import * as http from 'http'; 

Compilation says error TS2307: Cannot find module 'http'.

How to deal with this error?

Greetz

+6
source share
2 answers

This worked for me:

 npm install @types/node --save 

I understand that some time has passed with the OP, however this is a more updated answer if someone encounters this problem.

+9
source

I have the same problems. This is similar to what: https://github.com/TypeStrong/ts-node/issues/216

After setting the icons with:

 typings install dt~node --global --save 

And then added this to my file:

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

And suddenly it will work.

+1
source

All Articles