-
-
Save ThorsAngerVaNeT/cba280118a12a7561aba4d199246d208 to your computer and use it in GitHub Desktop.
Revisions
-
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ These launch configs will allow you to debug typescript files directly from VSCo { "type": "node", "request": "launch", "name": "ts-node - current file", "runtimeExecutable": "npx", "runtimeArgs": ["-y", "ts-node"], "program": "${file}", @@ -19,7 +19,7 @@ These launch configs will allow you to debug typescript files directly from VSCo { "type": "node", "request": "launch", "name": "ts-node - watch current file", "runtimeExecutable": "npx", "runtimeArgs": [ "-y", -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Debugging TypeScript with ts-node in VSCode These launch configs will allow you to debug typescript files directly from VSCode. It will honor the `tsconfig` and resolve node modules properly. You do not need to install `ts-node` or `nodemon`, as everything is run using `npx`. The first ## Launch Config -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,9 @@ These launch configs will allow you to debug typescript files directly from VSCo "nodemon", "-q", "--exec", "npx", "-y", "ts-node" ], "program": "${file}", "cwd": "${fileDirname}", -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 2 additions and 57 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ # Debugging TypeScript in VSCode These launch configs will allow you to debug typescript files directly from VSCode. It will honor the `tsconfig` and resolve node modules properly. You do not need to install `ts-node` or `nodemon`, as everything is run using `npx`. The first ## Launch Config ```json @@ -46,63 +46,8 @@ npx -y ts-node example.ts ``` It's better to use `cwd` in this way, as this allows for nested `tsconfig` files as may appear in a monorepo. The second one had to be a bit sneaky because of quirks in `nodemon`. They recently added TypeScript support, but internally it simply runs the `ts-node` command instead of `node`. However, to avoid the dependency for those using regular JS, they didn't add `ts-node` to its dependencies, so `npx nodemon` doesn't supply the dependency. You could avoid this by installing it in the project with `npm i -D ts-node`, but I wanted these to work without installing anything. This is solved with the `--exec` option by compounding `npx` scripts. The second config is equivalent to: ``` cd src/path/to npx -y nodemon -q --exec 'npx -y ts-node' ./example.ts ``` -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -52,7 +52,9 @@ cd src/path/to npx -y nodemon -q --exec 'npx -y ts-node' ./example.ts ``` HOWEVER, you can't directly do this with `runtimeArgs` in a launch config, because VSCode messes up the quotes. To hack around this, we use command expansion of the linux shell (sorry Windows users) combined with `echo`. The results of command expansion are The `runtimeExecutable` is `npx`, which allows running modules directly from `npm`. -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -52,7 +52,7 @@ cd src/path/to npx -y nodemon -q --exec 'npx -y ts-node' ./example.ts ``` HOWEVER, you can't directly do this with `runtimeArgs` in a launch config, because VSCode messes up the quotes. To hack around this, we use The `runtimeExecutable` is `npx`, which allows running modules directly from `npm`. -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,11 +46,13 @@ npx -y ts-node example.ts ``` It's better to use `cwd` in this way, as this allows for nested `tsconfig` files as may appear in a monorepo. The second one had to be a bit sneaky because of... quirks. `nodemon` recently added TypeScript support, but internally it simply runs the `ts-node` command instead of `node`. However, to avoid the dependency for those using regular JS, they didn't add `ts-node` to its dependencies. You could avoid this by installing it in the project with `npm i -D ts-node`, but I wanted these to work without installing anything. This can be solved with `nodemon`'s `--exec` option by compounding `npx` scripts: ``` cd src/path/to npx -y nodemon -q --exec 'npx -y ts-node' ./example.ts ``` HOWEVER, you can't directly do this with `runtimeArgs` in a launch config, because VSCode messes up the quotes. To hack around this The `runtimeExecutable` is `npx`, which allows running modules directly from `npm`. -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,10 +39,10 @@ These launch configs will allow you to debug typescript files directly from VSCo ``` ## Explanation The first one is pretty straightforward. If the file is `src/path/to/example.ts`, this is the equivalent of: ``` cd src/path/to npx -y ts-node example.ts ``` It's better to use `cwd` in this way, as this allows for nested `tsconfig` files as may appear in a monorepo. -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,7 +46,12 @@ npx -y ts-node three.ts ``` It's better to use `cwd` in this way, as this allows for nested `tsconfig` files as may appear in a monorepo. The second one had to be a bit sneaky because of the way that `nodemon` works. They recently added TypeScript support, but internally it simply runs the `ts-node` command instead of `node`. However, to avoid the dependency for those using regular JS, they didn't add `ts-node` to its dependencies. You could avoid this by installing it in the project with `npm i -D ts-node`, but I wanted these to work without installing anything. This can be solved with `nodemon`'s `--exec` option by compounding `npx` scripts: ``` ``` The `runtimeExecutable` is `npx`, which allows running modules directly from `npm`. -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ # Debugging TypeScript in VSCode These launch configs will allow you to debug typescript files directly from VSCode. It will honor the `tsconfig` and resolve node modules properly. You do not need to install `ts-node` or `nodemon`, as everything is run using `npx`. ## Launch Config ```json @@ -38,6 +38,18 @@ These launch configs will allow } ``` ## Explanation The first one is pretty straightforward. If the file is `src/one/two/three.ts`, this is the equivalent of: ``` cd src/one/two npx -y ts-node three.ts ``` It's better to use `cwd` in this way, as this allows for nested `tsconfig` files as may appear in a monorepo. The second one had to be a bit sneaky. `nodemon` has TypeScript support, but The `runtimeExecutable` is `npx`, which allows running modules directly from `npm`. ## Debug current file This launch config will run the current typescript file in the debugger. This does not require `ts-node` to be installed, as it runs through `npx`. ```jsonc -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ # Debugging TypeScript in VSCode These launch configs will allow ## Launch Config ```json -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 37 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,42 @@ # Debugging TypeScript in VSCode ## Launch Config ```json { "configurations": [ { "type": "node", "request": "launch", "name": "ts-node current file", "runtimeExecutable": "npx", "runtimeArgs": ["-y", "ts-node"], "program": "${file}", "cwd": "${fileDirname}", "console": "integratedTerminal", "internalConsoleOptions": "neverOpen" }, { "type": "node", "request": "launch", "name": "watch current file", "runtimeExecutable": "npx", "runtimeArgs": [ "-y", "nodemon", "-q", "--exec", "$(echo npx -y ts-node ${file})" ], "program": "${file}", "cwd": "${fileDirname}", "restart": true, "console": "integratedTerminal", "internalConsoleOptions": "neverOpen" }, ], } ``` ## Debug current file This launch config will run the current typescript file in the debugger. This does not require `ts-node` to be installed, as it runs through `npx`. ```jsonc -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ This launch config will run the current typescript file in the debugger. This do ``` # Live Reloads If you want live reloading, you can use the combination of `nodemon` and `ts-node`. Unfortunately, I havent found a way to do this without installing `ts-node` (see below). As in all cases, I strongly recommend adding it as a `devDependency` in your project rather than installing globally. ``` npm i -D ts-node @@ -36,7 +36,7 @@ Then you can use this configuration: "request": "launch", "name": "watch current file", "runtimeExecutable": "npx", "runtimeArgs": ["-y", "nodemon", "-q"], "program": "${file}", "cwd": "${fileDirname}", "restart": true, -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,8 @@ This launch config will run the current typescript file in the debugger. This do } ``` # Live Reloads If you want live reloading, you can use the combination of `nodemon` and `ts-node`. Unfortunately, I havent found a way to do this without installing `ts-node` (see below). As in all cases, I strongly recommend adding it as a `devDependency` in your project rather than installing globally. Global installs are the source of the vast majority of "works on my machine" problems. ``` npm i -D ts-node @@ -44,4 +45,5 @@ Then you can use this configuration: }, ], } ``` -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ # Debugging TypeScript in VSCode ## Debug current file This launch config will run the current typescript file in the debugger. This does not require `ts-node` to be installed, as it runs through `npx`. ```jsonc { "configurations": [ @@ -17,7 +20,7 @@ This launch config will run the current typescript file in the VSCode debugger. } ``` If you want live reloading, you can use the combination of `nodemon` and `ts-node`. Unfortunately, I havent found a way to do this without installing `ts-node`. The reason for this is that `nodemon` doesn't declare `ts-node` as a dependency, so `npx` doesn't add it. As in all cases, I strongly recommend adding it as a `devDependency` in your project rather than installing globally. Global installs are the source of the vast majority of "works on my machine" problems. ``` npm i -D ts-node -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 16 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,5 +25,20 @@ npm i -D ts-node Then you can use this configuration: ```jsonc { "configurations": [ { "type": "node", "request": "launch", "name": "watch current file", "runtimeExecutable": "npx", "runtimeArgs": ["-y", "nodemon"], "program": "${file}", "cwd": "${fileDirname}", "restart": true, "console": "integratedTerminal", "internalConsoleOptions": "neverOpen" }, ], } ``` -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ This launch config will run the current typescript file in the VSCode debugger. This does not require `ts-node` to be installed, as it runs through `npx`. ```jsonc { "configurations": [ { @@ -17,4 +17,13 @@ This launch config will run the current typescript file in the VSCode debugger. } ``` If you want live reloading, you can use the combination of `nodemon` and `ts-node`. Unfortunately, I havent found a way to do this without adding `ts-node` as a dev dependency. The reason for this is that `nodemon` doesn't declare `ts-node` as a dependency, so `npx` doesn't add it. ``` npm i -D ts-node ``` Then you can use this configuration: ```jsonc ``` -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ This launch config will run the current typescript file in the VSCode debugger. This does not require `ts-node` to be installed, as it runs through `npx`. ```json { "configurations": [ @@ -17,4 +17,4 @@ The following will run the typescript file currently opened in debug mode. This } ``` If you want live reloading, you can use the combination of `nodemon` and `ts-node`. Unfortunately, I havent found a way to do this without adding `ts-node` as a dev dependency. -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 18 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,20 @@ The following will run the typescript file currently opened in debug mode. This does not require `ts-node` to be installed, as it runs through `npx`. ```json { "configurations": [ { "type": "node", "request": "launch", "name": "ts-node current file", "runtimeExecutable": "npx", "runtimeArgs": ["-y", "ts-node"], "program": "${file}", "cwd": "${fileDirname}", "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", }, ], } ``` If you want live reloading -
ehaynes99 revised this gist
Jul 31, 2022 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,3 @@ ```json ``` -
ehaynes99 created this gist
Jul 31, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@