$ node -v
v16.13.0
I'm very new to TS/JS and try to understand how to import modules provided by node js with typescript. Following this How to use Node
http module in TypeScript
QA I tried it myself and wrote the following simple typescript file:
import * as http from "http"
When running tsc main.ts
I got the following error:
main.ts:1:23 - error TS2307: Cannot find module 'http' or its
corresponding type declarations.
Maybe some more options are required to the tsc? I tried to add tsc --module commonjs main.ts
but got the same error.
I thought all node js modules are visible for typescript by default.
this is all you need to do:')
import { http } from "http";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.