VS Code扩展调试启动失败,提示需设置outFiles属性求助
Hey there! Let's tackle this error you're hitting while debugging your VS Code extension (especially as you work on your JSON theme).
What does this error mean?
This message pops up because the VS Code debugger can’t locate the compiled JavaScript files it needs to run your extension. Most VS Code extension scaffolds use TypeScript, which gets transpiled to JS and saved to an out folder by default. Even if you’re focused on building a JSON theme, the core extension code from the scaffold still relies on this compiled output. If the debugger can’t find these files—either because they weren’t built yet, or the path in your debug config is incorrect—it throws this error.
How to check your file paths
Let’s start by verifying your debug configuration:
- Open
.vscode/launch.jsonin your project root - Check the
programfield: It should point to your extension’s compiled entry point, typically${workspaceFolder}/out/extension.js - Check the
outFilesfield: This should match all compiled JS files in youroutfolder, e.g.,${workspaceFolder}/out/**/*.js - Confirm the
outfolder exists in your project—if it doesn’t, your code hasn’t been compiled yet.
Quick Fix Steps
Here’s what to do to resolve this fast:
- First, manually compile your code: Open your terminal and run
npm run compile(this is included in the default extension scaffold’s scripts). You’ll see theoutfolder appear with your transpiled JS files. - Update your launch config: Make sure your
.vscode/launch.jsonhas these correct settings (adjust if your project structure differs):{ "version": "0.2.0", "configurations": [ { "name": "Run Extension", "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", "args": ["--extensionDevelopmentPath=${workspaceFolder}"], "outFiles": ["${workspaceFolder}/out/**/*.js"], "preLaunchTask": "npm: compile" } ] } - Enable auto-compile: To avoid this issue in the future, turn on TypeScript’s watch mode. Click the TypeScript icon in VS Code’s bottom-right corner, then select "Watch Mode" to automatically recompile code when you save changes.
If you’re working on a pure theme extension with no TypeScript code, you might need to tweak the launch config to skip looking for compiled files—but running the initial compile once should still make the default scaffold work.
内容的提问来源于stack exchange,提问作者Shabbir

