Nest.js / / 2023. 6. 12. 17:26

VSCode 에서 F5 Nest.js 실행하기

반응형

.vscode 안에 launch.json 파일 생성

[ Visual Studio Code 의 Run & Debug 메뉴에서 파일 생성 버튼으로 생성해도 됨]

 

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch via NPM",
            "type": "node",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "runtimeExecutable": "npm",
            "runtimeArgs": [
                "run-script", "start:dev"
            ],
            "console": "integratedTerminal"
        }
    ]
  }

package.json 파일 에서 실행 할 script 를 run-script 항목에 기재

 

  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  }

==> yarn 을 사용하는 경우

 

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch via YARN",
            "cwd": "${workspaceRoot}",
            "runtimeExecutable": "yarn",
            "runtimeArgs": [
                "start:debug"
            ],
            "stopOnEntry": false,
            "console": "integratedTerminal"
        }
    ]
}
반응형
  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유
  • 카카오스토리 공유