Error on debugging in protractor typescript cucumber code in vscode - Cannot read source map file | ENOENT: no such file or directory - node.js

vs code version - 1.47.2
launch.js file
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "BDD-Debug",
"protocol": "auto",
"program": "${workspaceFolder}\\node_modules\\protractor\\bin\\protractor",
"stopOnEntry": false,
"cwd": "${workspaceFolder}",
"args": [
"${workspaceFolder}\\transform\\config\\protractor.conf.js",
"--cucumberOpts.tags",
"#debug"
],
"preLaunchTask": "npm: build",
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/test/features/*.feature"],
"smartStep": true
}
]
}
Error in console:
C:\Program Files\nodejs\node.exe c:\Users\vn50ihd\WM_Project\GD_CCPA_QA_Automation\node_modules\protractor\bin\protractor C:\Users\vn50ihd\WM_Project\GD_CCPA_QA_Automation\transform\config\protractor.conf.js --
cucumberOpts.tags #debug
Debugger listening on
file:///C:/Users/vn50ihd/WM_Project/GD_CCPA_QA_Automation/e2e/model/pageObjects/affirmation.page.ts: ENOENT: no such file or directory, open 'c:\Users\vn50ihd\WM_Project\GD_CCPA_QA_Automation\e2e\model\e2e\model\pageObjects\transform\data:application\json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQzovVXNlcnMvdm41MGloZC9XTV9Qcm9qZWN0L0dEX0NDUEFfUUFfQXV0b21hdGlvbi9lMmUvbW9kZWwvcGFnZU9iamVjdHMvYWZmaXJtYXRpb24ucGFnZS50cyIsInNvdXJjZXMiOlsiQzovVXNlcnMvdm41MGloZC9XTV9Qcm9qZWN0L0dEX0NDUEFfUUFfQXV0b21hdGlvbi9lMmUvbW9kZWwvcGFnZU9iamVjdHMvYWZmaXJtYXRpb24ucGFnZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHNDQUFzQztBQUN0Qyw4Q0FBOEM7QUFDOUMseUNBQXdEO0FBRXhEO0lBT0U7UUFDRSxJQUFJLENBQUMsV0FBVyxHQUFHLG9CQUFPLENBQUMsZUFBRSxDQUFDLEtBQUssQ0FBQyx1QkFBdUIsQ0FBQyxDQUFDLENBQUM7UUFDOUQsSUFBSSxDQUFDLGdCQUFnQixHQUFHLG9CQUFPLENBQUMsZUFBRSxDQUFDLEtBQUssQ0FBQyw0QkFBNEIsQ0FBQyxDQUFDLENBQUM7UUFDeEUsSUFBSSxDQUFDLFFBQV

Related

VS Code , Node Js Debugger Not working. Could Not find any debuggable target

I am trying to debug nodejs code using Launch.json attach to process. I have tried following configuration
but debugger is not getting connected. my application is running on Node v6.11.5
Launch.json :--
{
"type": "node",
"name": "Attach by Process ID",
"request": "attach",
"processId": "${command:PickProcess}",
"skipFiles": [
"<node_internals>/**"
],
}
,Error getting displayed:
If you are using gulp you can use a configuration like this to launch the gulp task from VSCode using the Run->Start Debugging F5 command and debug it directly.
{
"version": "0.2.0",
"configurations": [
{
"name": "MyGulpTask",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"runtimeArgs": [
"--nolazy"
],
"console": "internalConsole",
}
]
}

Debugging doesn't work in Visual Studio Code 1.19.3

I want to use Visual Studio for developing an Node.js application with Typescript and simply want the normal debug behavior of any modern IDE: Debug code, set breakpoints, look into vars etc. Following the official documentation guide, I get an error when running the task: The npm task typescript didn't contribute a task for the following configuration.
So instead I invoke a custom npm script in the tasks.json file:
launch.json
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229,
"preLaunchTask": "typescript"
}
]
task.json
"tasks": [
{
"type": "shell",
"label": "typescript",
"command": "cd server; npm run build:live"
},
]
package.json
"scripts": {
"build:live": "nodemon --inspect --exec ./node_modules/.bin/ts-node -- ./index.ts"
}
Now the app is comping and starting (also with live reloading) fine. But NO debugging works, no breakpoint was reached. Is it really that hard to debug Typescript in VS Code?
I'm using the latest
Live debugging seems to be a pain on Typescript in VS Code. I could only make regular debugging working in a similar way to the full Visual Studio:
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/index.ts",
"outFiles": [
"${workspaceRoot}/dist/**/*.js"
],
"sourceMaps": true,
"stopOnEntry": false,
"cwd": "${workspaceRoot}",
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"internalConsoleOptions": "openOnFirstSessionStart",
"preLaunchTask": "compile",
"name": "DEBUG"
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "compile",
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Please note that you've to set "sourceMap": "true" in tsconfig.json. When not, an error occurs that corresponding source maps aren't found. This is cause NodeJS isn't able to compile TS. Compiling is done by the TypeScript compiler tscbefore. For debugging purpose (e.g. reach breakpoints) the source maps can map the compiled js to the ts source file here.

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.

Running babel-node in visual studio code

Normally to start up via command line, I can type:
babel-node server.js
When I try to set this up so that breakpoints and what not work in visual studio code I receive:
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js --debug-brk=31893 --nolazy server.js
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 1: /Applications: is a directory
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 3: /Applications: is a directory
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 4: Dockerfile: command not found
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 5: syntax error near unexpected token `('
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 5: ` * when found, before invoking the "real" _babel-node(1) executable.'
I surmise it has to do with the fact that the executable is being called from that directory, rather than from the same directory as the server.js file - but I really don't know.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/server.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": "${workspaceRoot}/node_modules/babel-cli/lib/babel-node.js",
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
The error occurs because the babel-node.js file is not the babel-node executable but a wrapper file that adds node flags:
babel-node.js
/* eslint indent: 0 */
/**
* This tiny wrapper file checks for known node flags and appends them
* when found, before invoking the "real" _babel-node(1) executable.
*/
To fix this, the location of the babel-node binary should be set as the value of the runtimeExecutable property. The location is:
"${workspaceRoot}/node_modules/.bin/babel-node"

Resources