The VSCode message "Cannot launch program ... setting the 'outDir' attribute might help" can be very misleading, even as recently as VSCode v1.12.2. It was caused by a minor error in my launch.json file. I had:
"type": "node",
"request": "launch",
"name": "Gulp",
"program": "${workspaceRoot}/node_modules/gulp/bin",
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/{lib,node_modules}/**/*.js",
"!${workspaceRoot}/lib/tests/**/*.js"
]
And fixed the problem by changing one line:
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp",
Despite what the message says, the outFiles property _may_ not be necessary. Once I fixed the other problem, debugging seems to work fine without it.
I bumped into a similar problem with program :"${file}". Turned out the editor was still focused on the launch.json file and it tried to run that file . Changing focus to the actual file that needs to be run runs the file .
Ugh.. a fix to this would be _greatly_ appreciated. I happen to be getting the same error, and from this ticket I can see that the real issue could be just about anything... even something in the debug console, output pane, etc. would be helpful! 馃槨
If the error message could be expanded to say that the type of the source file cannot be determined from the extension or contents, this might help. Refs #33051
@ovidiubuligan Can you expand further on how you solved the problem? I'm having the same issue. Not sure what to change in either or both my tsconfig.json and launch.json. Thank you. 馃檹馃徔
EDIT
I figured out my problem. I got rid of the "program" option in launch.json and now it works as I expect it to.
disable Java Extension by Red Hat, I find it fixed in JavaScript project 馃槂
I found that I get this error message when I try and debug a node script on Unix (osx) when the script does not have the .js extension.
Hey Microsoft vscode folks. Unix shell scripts don't require an extension to figure out the interpreter they figure it out from first line:
Please support this. Or baring that please print a better error message.
@pogilvie we are actually looking at the shebang!
But using a non-portable path like "#!/usr/local/bin/node" is not the recommended approach (and we
do not support it).
Please use a portable shebang instead:
#!/usr/bin/env node
For details see https://stackoverflow.com/questions/33509816/what-exactly-does-usr-bin-env-node-do-at-the-beginning-of-node-files
Thank you! This is helpful. I will note that vscode seems picks up the javascript language correctly when the shebang is set which is something atom didn't do but emacs and vim do.
I need this fixed for when the file doesn't have a .js extension, e.g. .ts.
@seangenabe this works fine for ".ts" files. Please file a new issue with detailed steps what is not working for you.
The original problem is long forgotten. I'll mark it closed.
Most helpful comment
I bumped into a similar problem with
program :"${file}". Turned out the editor was still focused on thelaunch.jsonfile and it tried to run that file . Changing focus to the actual file that needs to be run runs the file .