Debugger being skipped during gatsby develop process - node.js

Help please, I use to be able to place debugger/breakpoints in the build process of gatsby and debug fine but this is no longer working. It ignores the "debugger". Console.log works fine. Heres my lunch.json, it was working with this setting prior but no longer is.
{
"version": "0.2.0",
"configurations": [
{
"name": "Gatsby develop",
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "${workspaceRoot}/node_modules/gatsby/dist/bin/gatsby",
"args": ["develop"],
"stopOnEntry": false,
"runtimeArgs": ["--nolazy"],
"sourceMaps": false
},
{
"name": "Gatsby build",
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "${workspaceRoot}/node_modules/gatsby/dist/bin/gatsby",
"args": ["build"],
"stopOnEntry": false,
"runtimeArgs": ["--nolazy"],
"sourceMaps": false
},
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:8000",
"webRoot": "${workspaceFolder}"
}
]
}

Related

VS code debugger variables not showing up

I am trying to debug a test in vscode.
jest is runner.
Here is my launch configuration.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true }
]
}
Using this when i launch the debugger it stops at breakpoint but none of the variables show up in local variable pane.
image
Try this (if u are on windows):
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
}
},
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"${fileBasenameNoExtension}",
"--config",
"jest.config.js"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
}
}
]
}

Not connected to runtime

I am trying to debug my nodejs code in debug mode, but I am getting the following error in the debug console. Any idea?
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug content-service",
"program": "${workspaceFolder}\\src\\app.js",
"cwd": "${workspaceFolder}\\src",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
"name": "Debug test",
"program": "${workspaceFolder}\\src\\node_modules\\lab\\bin\\lab",
"args": [
"--colors",
"${workspaceFolder}\\src\\test\\test.js"
],
"cwd": "${workspaceFolder}\\src",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
it works if I am not in debug mode.

VSCode node debugger

Hi there I am trying to set up breakpoints in VSCode and use the Chrome debugger. My repo has a Node JS server that runs on http://localhost.lmig.com:3000/.
The main npm command that I need to run is npm start.
My node version is 6.10.0. My local os is Mac OSX and I use zsh with NVM. So far my launch.json is this:
configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost.lmig.com:3000/",
"webRoot": "${workspaceFolder}"
},{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeVersion": "6.10.0",
"runtimeArgs": [
"run-script",
"start",
"--debugger=3000"
],
"port": 3000,
"restart": true,
"protocol": "legacy",
"remoteRoot": "0.0.0.0:3000",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
// "outFiles": ["${workspaceRoot}/build/**/*.js"],
"sourceMaps": true
}
My package.json is this:
It runs the node process in the integrated terminal but still doesn't seem to hit my breakpoints.
Please help
Just providing this as an alternative launch config, but it is what I use.
You may need to change your "protocol" back to legacy... since you're on an older version of node.
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Debug",
"type": "node",
"request": "launch",
"restart": true,
"program": "${workspaceRoot}/bin/www",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": "build",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development",
"PORT": "3000"
},
"console": "internalConsole",
"outputCapture": "std",
"sourceMaps": true,
"protocol": "inspector",
"skipFiles": [
"${workspaceRoot}/node_modules/**/*.js",
"${workspaceRoot}/lib/**/*.js",
"<node_internals>/**/*.js"
],
"internalConsoleOptions": "openOnSessionStart"
}
]
}

Debugging CoffeeScript in VSCode goes to .js files

I am trying to debug a CoffeeScript file in vs code. It works and I can step through the compiled.js files. However, I can't step through the actual CoffeeScript files.
Here is my launch.json file:
{
"type": "node",
"request": "launch",
"name": "Launch Meeting",
"program": "${workspaceRoot}/lib/meeting/meeting-service.coffee",
"cwd": "${workspaceRoot}",
"env": {
"NODE_ENV": "local"
},
"sourceMaps": true
}
And in another window, I am running:
./node_modules/.bin/coffee -mc --watch lib/activity/note-activity-model.coffee \
lib/activity/note-activity-publisher.coffee \
lib/app-event-queue.coffee \
lib/meeting/meeting-api.coffee \
lib/meeting/meeting-service.coffee \
lib/meeting/meeting-socket-service.coffee \
lib/meeting/meeting-util.coffee
When I set a breakpoint in the coffee file, the debugger halts on the compiled js file. I need it on the coffee file.
Did you try to use
"stopOnEntry": true,
"smartStep": false
as described in https://github.com/Microsoft/vscode/issues/5963 ?
Also, always from that source, a working example (assuming a coffeescript file in your workspace named coffee.coffee:
{
"name": "Coffee",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/coffee.coffee",
"cwd": "${workspaceRoot}",
"sourceMaps": true,
"stopOnEntry": true,
"smartStep": false
}
here is my launch config:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}", //improtant, that debug current coffee.
"outFiles": [ //most important, can not debug without this.
"${workspaceFolder}/dist/api/api.js"
]
}
]
}

debugging typescript in vscode with autorestart

I am setting up a typescript project with node.
I can debug my main.ts file in vs code with this launch.json configuration:
{
"type": "node",
"request": "launch",
"name": "Lancer le programme",
"program": "${workspaceRoot}/src/main.ts",
"outFiles": [
"${workspaceRoot}/dist/**/*.js"
]
}
This works fine but there is no auto restart when I edit main.ts
To implement auto restart, I launch in my project directory tsc --watch, and then this lauch configuration:
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "nodemon",
"runtimeArgs": [
"--debug=5858"
],
"program": "${workspaceRoot}/src/main.ts",
"outFiles": [
"${workspaceRoot}/dist/**/*.js"
],
"restart": true,
"port": 5858,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true
},
The above configuration does autorestart when I edit source files, but the vscode debugger doesn't break anymore...
Has anyone achieved : debugging typscript in vscode with autorestart ?
This is my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
"program": "${workspaceFolder}/build/index.js",
"restart": true,
"runtimeArgs": [
"--debug=5858",
"--inspect-brk"
],
"port": 5858,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
Note that the prop program must indicate compiled js file. In your case it is ${workspaceRoot}/src/main.ts, but should be ${workspaceRoot}/*compile directory eg. build*/main.js.
Also make sure the typescript recompiles the files to the target directory.

Resources