6
    import http from 'http';
    http.createServer((req, res) => {
      res.end('Hello World');
    }).listen(3000, () => console.log('Port is running on 3000'));

I am using @types/node but it shows an error HTTP module does not have default export.

  • Does this answer your question? [error TS1192: Module '" A.module"' has no default export](https://stackoverflow.com/questions/40429927/error-ts1192-module-a-module-has-no-default-export) – SternK Mar 26 '21 at 10:14

4 Answers4

13

You probably need to import the module like this

import * as http from 'http'

omeanwell
  • 1,847
  • 1
  • 10
  • 16
1
{
    "compilerOptions": {
        "esModuleInterop": true
    },

}

Just add esModuleInterop at your tsconfig.json file

Tanjin Alam
  • 1,728
  • 13
  • 15
-1

import { HttpClientModule } from '@angular/common/http'

saudblaze
  • 150
  • 10
-2

To be honest with you, it's probably not an import problem as the first answer points out, import http from 'http' works more than fine. The issue is in the IDE to be more specific an indexing/memory issue, so what you do?

Restart

adtoctor
  • 58
  • 9