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

1

4 Answers 4

15

You probably need to import the module like this

import * as http from 'http'

Sign up to request clarification or add additional context in comments.

1 Comment

esModuleInterop: true at your tsconfig file
11
{
    "compilerOptions": {
        "esModuleInterop": true
    },

}

Just add esModuleInterop at your tsconfig.json file

Comments

-1

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

1 Comment

Not Specific to Angular
-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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.