Closed nyj001012 closed 2 months ago
📦[scarf@node-slim backend]$ pnpm start dev
> backend@0.0.1 start /run/media/home/scarf/repo/lib42/backend-nest/backend
> nest start "dev"
src/histories/histories.controller.ts:6:30 - error TS2307: Cannot find module 'nestjs-zod' or its corresponding type declarations.
6 import { zodToOpenAPI } from 'nestjs-zod';
~~~~~~~~~~~~
Found 1 error(s).
ELIFECYCLE Command failed with exit code 1
존재하지 않는 nestjs-zod
에서 zodToOpenAPI
를 가져오려고 시도하면서 발생한 오류인데 다른 오류 메시지가 나오는 것 같습니다.
diff --git a/backend/src/histories/histories.controller.ts b/backend/src/histories/histories.controller.ts
index ce2b9fa..6189f18 100644
--- a/backend/src/histories/histories.controller.ts
+++ b/backend/src/histories/histories.controller.ts
@@ -3,7 +3,9 @@ import { ApiOperation, ApiResponse } from '@nestjs/swagger';
import { HistoriesService } from 'src/histories/histories.service';
import { getHistoriesDto } from 'src/histories/dto/histories.dto'; // Adjust the import path as necessary
import { getHistoriesResponseSchema } from './schema/histories.schema';
-import { zodToOpenAPI } from 'nestjs-zod';
+import { createZodDto } from '@anatine/zod-nestjs';
+
+class HistoriesResponseDTO extends createZodDto(getHistoriesResponseSchema) {}
@Controller('histories')
export class HistoriesController {
@@ -19,7 +21,7 @@ export class HistoriesController {
@ApiResponse({
status: 200,
description: '대출 기록을 반환한다.',
- schema: zodToOpenAPI(getHistoriesResponseSchema),
+ type: HistoriesResponseDTO,
})
getHistories(@Query() query: getHistoriesDto) {
return this.historiesService.getHistories();
다음과 같이 수정한 후 다시 시도해보시겠어요?
📦[scarf@node-slim backend]$ pnpm start dev > backend@0.0.1 start /run/media/home/scarf/repo/lib42/backend-nest/backend > nest start "dev" src/histories/histories.controller.ts:6:30 - error TS2307: Cannot find module 'nestjs-zod' or its corresponding type declarations. 6 import { zodToOpenAPI } from 'nestjs-zod'; ~~~~~~~~~~~~ Found 1 error(s). ELIFECYCLE Command failed with exit code 1
존재하지 않는
nestjs-zod
에서zodToOpenAPI
를 가져오려고 시도하면서 발생한 오류인데 다른 오류 메시지가 나오는 것 같습니다.diff --git a/backend/src/histories/histories.controller.ts b/backend/src/histories/histories.controller.ts index ce2b9fa..6189f18 100644 --- a/backend/src/histories/histories.controller.ts +++ b/backend/src/histories/histories.controller.ts @@ -3,7 +3,9 @@ import { ApiOperation, ApiResponse } from '@nestjs/swagger'; import { HistoriesService } from 'src/histories/histories.service'; import { getHistoriesDto } from 'src/histories/dto/histories.dto'; // Adjust the import path as necessary import { getHistoriesResponseSchema } from './schema/histories.schema'; -import { zodToOpenAPI } from 'nestjs-zod'; +import { createZodDto } from '@anatine/zod-nestjs'; + +class HistoriesResponseDTO extends createZodDto(getHistoriesResponseSchema) {} @Controller('histories') export class HistoriesController { @@ -19,7 +21,7 @@ export class HistoriesController { @ApiResponse({ status: 200, description: '대출 기록을 반환한다.', - schema: zodToOpenAPI(getHistoriesResponseSchema), + type: HistoriesResponseDTO, }) getHistories(@Query() query: getHistoriesDto) { return this.historiesService.getHistories();
다음과 같이 수정한 후 다시 시도해보시겠어요?
PATH
에 node_modules
경로 등록해두니까 실행됐네요,
zodToOpenAPI
는 import되어 있는 상태예요
개요
pnpm start:dev
시@nestjs/common
모듈을 찾지 못하는 문제 발생로그
시도해본 것
node_modules
삭제 후 패키지 재설치@nestjs/common
만 수동 설치pnpm store prune
,node_modules
삭제 후 패키지 재설치pnpm link --global