Steps to Reproduce:
Config:
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/src/index.ts",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/dist/**/*.js" ]
},
Sounds like a potential regression - adding important to raise awarness. @weinand feel free to remove the tag if I am mistaken.
I experienced a very similar issue.
I tried to reproduce this problem on Windows 10 with a similar setup, but I could not get this to fail.
Could you please add a trace attribute for source maps ('sm') to your launch config:
"trace": "sm"
and relaunch debugging.
Do you see any problems being logged to the debug console?
(if you replace 'sm' by 'all' you get even more trace information)
I can't get to that point, the error pops up before anything is traced
"sm" or "all" - makes no difference
@chris-jones-pixitmedia I've just tried to simulate your problem and before getting the error pop up I get this trace output:
3480: _findSourceMapUrl: source map url found at end of generated file 'c:/Users/weinand/Projects/TestData/TS/out/bug_1746.js'
3480: _findSourceMapUrl: source map url found at end of generated file 'c:/Users/weinand/Projects/TestData/TS/out/bug_1047.js'
3480: _findSourceMapUrl: source map url found at end of generated file 'c:/Users/weinand/Projects/TestData/TS/out/bug_xyz.js'
3480: _registerSourceMap: c:/users/weinand/projects/testdata/ts/src/bug_1047.ts -> c:/users/weinand/projects/testdata/ts/out/bug_1047.js
3480: _registerSourceMap: c:/users/weinand/projects/testdata/ts/src/bug_xyz.ts -> c:/users/weinand/projects/testdata/ts/out/bug_xyz.js
3480: _registerSourceMap: c:/users/weinand/projects/testdata/ts/src/bug_1746.ts -> c:/users/weinand/projects/testdata/ts/out/bug_1746.js
This output is the result from scanning the "outFiles" glob pattern.
Since you are not seeing this output it means that VS Code is not finding anything under your "${workspaceRoot}/dist/**/*.js". Could you please make sure that:
//# sourceMappingURL= and a path at the end, Hi @weinand,
I managed to get "trace": "all" working.
JS files have been compiled and are in the out directory, all have //# sourceMappingUrl = and a path, all of which point to valid source maps.
Trace outputs a ton of _findSourceMapUrl messages, followed by corresponding _registerSourceMap messages. Final message is:
disconnectRequest: send response
And in the trace output a "_registerSourceMap" exists for your "${workspaceRoot}/src/index.ts" file?
Yes
Please copy the full path of your "index.ts" from the trace output in the debug console into the launch config as the value for the "program" attribute and then start debugging.
My theory is that the drive letter in "${workspaceRoot}/src/index.ts" uses a different case than what node.js sees.
BTW, what version of node are you using?
Got it working! Looks like this was to do with gulp-sourcemaps rather than vscode - not sure why it was working before the upgrade and not after though.
sourceRoot in each map was set to 'source'. Explicitly set the sourceRoot option in gulp-sourcemaps to "../src" and it started working again.
Thanks for you help.
@chris-jones-pixitmedia great to hear that you got this working again.
Yes, gulp-sourcemaps is a mixed blessing. Just Yesterday their 1.8 version was breaking everyone: https://github.com/floridoo/gulp-sourcemaps/issues/238
In my case, explicitly mentioning the index.js / server.js file against outFiles property did the trick. As opposed to just clubbing everything like "${workspaceRoot}/build/local/**/*.js",
My outFiles property:
"outFiles": [
"${workspaceRoot}/build/local/server.js",
"${workspaceRoot}/build/local/app/**/*.js"
]
@akshaysinghal hmm, having to break your single pattern into two sounds strange. I'll investigate...
@weinand any update on this? I have this set up
"outFiles": ["${workspaceRoot}/js"]
but when I run it via Ctrl + F5, it says:
Cannot launch program 'd:\Work\datachimp\app.ts'; setting the 'outFiles' attribute might help.
My .ts files are compiling fine and are being outputted to the js directory.
The values of the attribute outFiles must be glob patterns.
So if your generated *.js files live anywhere in the 'js' directory, the pattern would be:
"outFiles": [ "${workspaceRoot}/**/*.js" ]
Nice @weinand, that did it! :+1:
@Ciwan1859 actually the correct pattern should be this:
"outFiles": [ "${workspaceRoot}/js/**/*.js" ]
otherwise the debugger will search for JavaScript everywhere in your project folder.
Hi I am getting the same problem and I mentioned my outfiles path as
"outFiles": [
"${workspaceRoot}/*/.js"
]
but it still is showing error of setting outfiles attribute might help?
@pavankumar58 this issue was closed. Please file a new issue with detailed steps for how to reproduce.
Most helpful comment
@Ciwan1859 actually the correct pattern should be this:
otherwise the debugger will search for JavaScript everywhere in your project folder.