diff --git a/.vscode/launch.json b/.vscode/launch.json index 1908379..d4e0208 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,21 +7,9 @@ { "type": "node", "request": "attach", - "name": "Attach", - "port": 9229 - }, - { - "type": "node", - "request": "launch", - "name": "Debug", - "program": "${workspaceRoot}/dist/server.js", - "smartStep": true, - "outFiles": [ - "../dist/**/*.js" - ], - "preLaunchTask": "npm: build", + "name": "Attach by Process ID", + "processId": "${command:PickProcess}", "protocol": "inspector" } ] -} - +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index bbd793f..6034f76 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,5 +8,8 @@ "typescript.referencesCodeLens.enabled": true, "tslint.ignoreDefinitionFiles": false, "tslint.autoFixOnSave": true, - "tslint.exclude": "**/node_modules/**/*" + "tslint.exclude": "**/node_modules/**/*", + "cSpell.words": [ + "definitelytyped" + ] } \ No newline at end of file diff --git a/README.md b/README.md index 77eefb7..ebd9bdb 100644 --- a/README.md +++ b/README.md @@ -276,37 +276,19 @@ In this file, you can tell VS Code exactly what you want to do: ```json { "type": "node", - "request": "launch", - "name": "Debug", - "program": "${workspaceRoot}/dist/server.js", - "smartStep": true, - "outFiles": [ - "../dist/**/*.js" - ], + "request": "attach", + "name": "Attach by Process ID", + "processId": "${command:PickProcess}", "protocol": "inspector" } ``` -This is mostly identical to the "Node.js: Launch Program" template with a couple minor changes: +This is mostly identical to the "Node.js: Attach by Process ID" template with one minor change. +We added `"protocol": "inspector"` which tells VS Code that we're using the latest version of Node which uses a new debug protocol. -| `launch.json` Options | Description | -| ----------------------------------------------- | --------------------------------------------------------------- | -| `"program": "${workspaceRoot}/dist/server.js",` | Modified to point to our entry point in `dist` | -| `"smartStep": true,` | Won't step into code that doesn't have a source map | -| `"outFiles": [...]` | Specify where output files are dropped. Use with source maps | -| `"protocol": inspector,` | Use the new Node debug protocol because we're on the latest node| - -With this file in place, you can hit `F5` to serve the project with the debugger already attached. +With this file in place, you can hit `F5` to attach a debugger. +You will probably have multiple node processes running, so you need to find the one that shows `node dist/server.js`. Now just set your breakpoints and go! -> Warning! Make sure you don't have the project already running from another command line. -VS Code will try to launch on the same port and error out. -Likewise be sure to stop the debugger before returning to your normal `npm start` process. - -#### Using attach debug configuration -VS Code debuggers also support attaching to an already running program. The `Attach` configuration has already configured, everything you need to do is change `Debug Configuration` to `Attach` and hit `F5`. - -> Tips! Instead of running `npm start`, using `npm run debug` and `Attach Configuration` that make you don't need to stop running project to debug. - ## Testing For this project, I chose [Jest](https://facebook.github.io/jest/) as our test framework. While Mocha is probably more common, Mocha seems to be looking for a new maintainer and setting up TypeScript testing in Jest is wicked simple.