Skip to content

Instantly share code, notes, and snippets.

@itssimmons
Last active April 15, 2022 04:42
Show Gist options
  • Save itssimmons/e2765eeba1781c7185ced3187b3bbda0 to your computer and use it in GitHub Desktop.
Save itssimmons/e2765eeba1781c7185ced3187b3bbda0 to your computer and use it in GitHub Desktop.
Debug deno on vscode
/**
* @description create a to recreate the fibonacci sequence and returns it into an array
* @param n total of loops
* @returns and array filled with fibonacci sequence
* @example [0,1,1,2,3,5,8,13,21...]
*/
export function fibonashi(n: number): unknown[] {
const a: number[] = [0, 1];
if (n === 1) return [0];
if (n === 2) return [0, 1];
for (let i = 2; i < n; ++i) {
a[i] = a[i - 1] + a[i - 2];
}
return a;
}
console.log(fibonashi(9));
{
"version": "0.2.0",
"configurations": [
{
"request": "launch",
"name": "Launch Program",
"type": "node",
"program": "${workspaceFolder}/index.ts", // replace to your main file
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"outputCapture": "std", // this will output things on DEBUG CONSOLE
"runtimeArgs": [
"run",
"--unstable",
"--inspect-brk",
// ^ important, see the quote on https://deno.land/manual@v1.19.1/getting_started/debugging_your_code#debugging-your-code
"--allow-all"
],
"attachSimplePort": 9229
}
]
}
@itssimmons
Copy link
Author

itssimmons commented Apr 15, 2022

The quote says:

⚠️ If you use --inspect flag, the code will start executing immediately. If your program is short, you might not have enough time to connect the debugger before the program finishes execution. In such cases, try running with --inspect-brk flag instead, or add a timeout at the end of your code.

@itssimmons
Copy link
Author

Error at lauch.json because is not a .jsonc file, but in vscode work as .jsonc, so don't worry about it

@itssimmons
Copy link
Author

itssimmons commented Apr 15, 2022

⚠️ you must have open chrome://inspect in the browser, and configure your network targets to work with your current debugging session, when you will see your file in Remote Target it is because everything is working fine!

@itssimmons
Copy link
Author

If you have errors at the key "type" in launch.json surely it is because you don't have anything to run the node debugger so I recommend you to install: https://marketplace.visualstudio.com/items?itemName=ms-vscode.js-debug-nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment