Search code examples
visual-studio-codevscode-extensions

VSCode Extension: Command 'Hello World' resulted in an error (command 'vscode-err-reproduce.helloWorld' not found)


Problem Description:

I tried creating VS Code extension using the sample extension (yo code) provided in the documentation. I chose "typescript" as it's type of extension, while creating it. When I tried to run the extension, I get an error message .

Command 'Hello World' resulted in an error (command 'vscode-err-reproduce.helloWorld' not found)
Activating extension 'undefined_publisher.vscode-err-reproduce' failed: Cannot find module
 '/oct/vscode-extn-ts-error/vscode-err-reproduce/out/extension.js' Require stack: - /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js - /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js - /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js.

tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "ES2020",
        "outDir": "out",
        "lib": [
            "ES2020"
        ],
        "sourceMap": true,
        "rootDir": "src",
        "strict": true   /* enable all strict type-checking options */
        /* Additional Checks */
        // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
        // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
        // "noUnusedParameters": true,  /* Report errors on unused parameters. */
    },
    "exclude": [
        "node_modules",
        ".vscode-test"
    ]
}

Solution

  • The error is due to the compilation not running or failing to run at the launch of the extension. Hence .js file not getting created on /out/* directory

    1. I solved the issue, by manually running tsc --watch from the root directory.
    2. I thought, the launch of the extension by default trigger the compilation, but that wasn't the case.
    3. The product documentation says,"press F5. This will compile and run the extension in a new Extension Development Host window." However, this isn't the case for me. Not sure, where it was actually failing .
    4. I've opened up an bug with Microsoft for this issue.

    https://github.com/microsoft/vscode-extension-samples/issues/510