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

typescript nodes visual-studio-code

9634 просмотра

2 ответа

313 Репутация автора

i'm using Visual Studio Code for NodeJS and Typescript development. If I'm writing this code:

import * as http from 'http'; 

The compile says error TS2307: Cannot find module 'http'.

How to handle this error?


Автор: R3Tech Источник Размещён: 18.07.2016 10:52

Ответы (2)

1 плюс

5772 Репутация автора

I have the same issues. It's similar to that: https://github.com/TypeStrong/ts-node/issues/216

After installing the typings 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 works.

Автор: Andre Bossard Размещён: 29.11.2016 09:30

41 плюса

411 Репутация автора

This worked for me:

npm install @types/node --save

I realise it's been a while since the OP, however this is a more updated answer in case someone stumbles across this problem.

Автор: user2932298 Размещён: 17.04.2017 11:50
Вопросы из категории :