티스토리 뷰

Programming/Node.js

Node.js : NestJS 설치

파란크리스마스 2024. 8. 4. 17:34
728x90

출처

설치

yarn 설치

Yarn은 프로젝트 관리자의 역할을 하는 패키지 관리자입니다. 간단한 프로젝트에서 작업하든 업계 단일 레포에서 작업하든, 오픈 소스 개발자이든 엔터프라이즈 사용자이든 Yarn이 지원합니다.

D:\workspace.nodejs>npm install -g yarn

nestjs 설치

D:\workspace.nodejs>npm i -g @nestjs/cli

프로젝트 생성

D:\workspace.nodejs>nest new nestjs_example
⚡  We will scaffold your app in a few seconds..

? Which package manager would you ❤️  to use? yarn
CREATE nestjs_example/.eslintrc.js (688 bytes)
CREATE nestjs_example/.prettierrc (54 bytes)
CREATE nestjs_example/nest-cli.json (179 bytes)
CREATE nestjs_example/package.json (2022 bytes)
CREATE nestjs_example/README.md (3420 bytes)
CREATE nestjs_example/tsconfig.build.json (101 bytes)
CREATE nestjs_example/tsconfig.json (567 bytes)
CREATE nestjs_example/src/app.controller.ts (286 bytes)
CREATE nestjs_example/src/app.module.ts (259 bytes)
CREATE nestjs_example/src/app.service.ts (150 bytes)
CREATE nestjs_example/src/main.ts (216 bytes)
CREATE nestjs_example/src/app.controller.spec.ts (639 bytes)
CREATE nestjs_example/test/jest-e2e.json (192 bytes)
CREATE nestjs_example/test/app.e2e-spec.ts (654 bytes)

√ Installation in progress... ☕

🚀  Successfully created project nestjs_example
👉  Get started with the following commands:

$ cd nestjs_example
$ yarn run start


                          Thanks for installing Nest 🙏
                 Please consider donating to our open collective
                        to help us maintain this package.


               🍷  Donate: https://opencollective.com/nest


D:\workspace.nodejs>

src\main.ts 소스

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(3000);
}
bootstrap();

실행

npm run start:dev 를 입력하면, 변경사항이 감지되었을 경우 직접 서버를 다시 키지 않아도 이를 감지하여 서버를 자동으로 재시동해준다.

D:\workspace.nodejs>cd nestjs_example

D:\workspace.nodejs\nestjs_example>npm run start

> nestjs_example@0.0.1 start
> nest start

[Nest] 2784  - 2024. 08. 07. 오후 11:53:47     LOG [NestFactory] Starting Nest application...
[Nest] 2784  - 2024. 08. 07. 오후 11:53:47     LOG [InstanceLoader] AppModule dependencies initialized +7ms
[Nest] 2784  - 2024. 08. 07. 오후 11:53:47     LOG [RoutesResolver] AppController {/}: +3ms
[Nest] 2784  - 2024. 08. 07. 오후 11:53:47     LOG [RouterExplorer] Mapped {/, GET} route +1ms
[Nest] 2784  - 2024. 08. 07. 오후 11:53:47     LOG [NestApplication] Nest application successfully started +2ms
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함