Development/Typescript

[Typescript] TypeError: koa_1.default is not a constructor

StudyGPT 2023. 12. 23.

이슈

- app.ts

import Koa from 'koa';
const app = new Koa();
app.use(req => {
  req.body = 'hello world';});
export default app;

- server.ts
import app  from './app';
app.listen(4000, () => {
  console.log("Server is Listening to port 4000");});
 

 

- Error

# ts-node-dev --respawn ./src/server.ts
TypeError: koa_1.default is not a constructor
 

해결

- app.ts

import * as Koa from 'koa';

댓글