ash*_*ngi 8 node.js typescript
import http from 'http';
http.createServer((req, res) => {
res.end('Hello World');
}).listen(3000, () => console.log('Port is running on 3000'));
Run Code Online (Sandbox Code Playgroud)
我正在使用 @types/node 但它显示错误 HTTP 模块没有默认导出。
ome*_*ell 13
您可能需要像这样导入模块
import * as http from 'http'
{
"compilerOptions": {
"esModuleInterop": true
},
}
Run Code Online (Sandbox Code Playgroud)
只需在 tsconfig.json 文件中添加 esModuleInterop
| 归档时间: |
|
| 查看次数: |
8522 次 |
| 最近记录: |