"Attribute 'program' does not exist" for basic node.js project

The error is saying that the path to your code was wrong.

VSCode defines the parent directory of its configuration file ".vscode/launch.json" as "${workspaceRoot}" or "${workspaceFolder}".

So, for example, if you want to run file "myproject/subfolder/main.js", you should configure your "myproject/.vscode/launch.json" as follows: "program": "${workspaceRoot}/subfolder/main.js"

Note that configuring "program": "${workspaceRoot}/myproject/subfolder/main.js" is a mistake and will cause error "Attribute 'program' does not exist".


I believe that you need ${workspaceRoot}/server.js, not ${workspaceRoot}/app.js for program. The code you're using doesn't have an app.js, that's what that (poorly worded) error is telling you.


I also encountered this issue because of where VS Code put the .vscode directory containing the launch.json file. It put it up one directory so I had to add the directory to the path as defined in the launch.json file:

"program": "${workspaceRoot}/myDir/app.js",

I hope this helps.


Another issue I ran into is a path was configured Using\\Backslashes\\Like\\So and worked fine on Windows, but on Mac it gave the above error.

(Solution: changed to /)