[NestJS 오류] TypeError: (0 , cookie_parser_1.default) is not a function

Kim jae-eok·2022년 9월 29일
0

아래와 같은 오류를 만났다.

[Nest] 21927  - 2021. 11. 09. 오후 3:38:42     LOG [InstanceLoader] TypeOrmCoreModule dependencies initialized +47ms
[Nest] 21927  - 2021. 11. 09. 오후 3:38:42     LOG [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 21927  - 2021. 11. 09. 오후 3:38:42     LOG [InstanceLoader] AuthModule dependencies initialized +0ms
[Nest] 21927  - 2021. 11. 09. 오후 3:38:42     LOG [InstanceLoader] UsersModule dependencies initialized +1ms
[Nest] 21927  - 2021. 11. 09. 오후 3:38:42     LOG [InstanceLoader] AppModule dependencies initialized +0ms
/Users/xii/src/main.ts:28
  app.use(cookieParser());
                      ^
TypeError: (0 , cookie_parser_1.default) is not a function
    at bootstrap (/Users/im-uchan/Desktop/~~~~~/src/main.ts:28:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
import cookieParser from 'cookie-parser';
    //...........
app.use(cookieParser());

import때문에 발생한 문제이다.

tsconfig.json에 들어가 "esModuleInterop": true를 추가해주자.

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,  // 추가
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false
  }
}
profile
블로그 이전 중 (https://www.notion.so/My-blog-0d569b9028434fb6a99a3e66b6e807b1)

1개의 댓글

comment-user-thumbnail
2023년 6월 22일

감사합니다 선생님

답글 달기