0
votes

We're setting up a new OSx machine and getting this message when trying to launch and debug a TypeScript based node app:

Cannot launch program '/Projects/is/0.0.34/server/server/server.ts'; setting the 'outDir or outFiles' attribute might help.

We've been using the same launch config for over a year and we're not writing the output to a separate directory, so there should no need to set 'outFiles'. The program runs fine from the command prompt. However, trying to launch the app in VsCode is now returning the error above. We did recently upgraded to Node v8.5.0 from v7.3.0. Based on the docs this should still work. The other posts regarding this issue relate to issues resulting from writing the source (and sourcemaps) to a different directory.

launch.json

{
    "configurations": [
        {
            "name": "Launch Program",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/server/server.ts",
            "cwd": "${workspaceRoot}"
        }
    ]
}

Here's the tsconfig:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true,
        "watch": true,
        "allowUnreachableCode": true,
        "noImplicitUseStrict": true
    }
}
2

2 Answers

0
votes

The "outFiles" setting appears to now be required for Node + TypeScript project using VsCode. I added this to the launch.json and its now working.

"outFiles": [
    "${workspaceRoot}/**/*.js"
]
0
votes

Use like this your launch.json file.

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [ 

{
    "type": "node",
    "request": "launch",
    "name": "Launch Program",
    "program": "${workspaceFolder}/yourjsfile.js"
},
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${file}",
        "outFiles": [
            "${workspaceFolder}/**/*.js"
        ]
    }
]
}