Search code examples
visual-studio-codevscode-extensions

Why does VSCode give me an error when trying to run a javascript file using CodeRunner extension?


I created a temporary file in VSCode, I hit the run ▸ button, located at the top left of the screen, which comes with the CodeRunner extension, but it keeps giving me:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".javascript" for c:\foo\bar\baz-fooo\baaaaaar.javascript

I tried to set the language mode to Javascript (which was already set to Javascript), but I kept getting the same error.


Solution

  • CodeRunner uses node to run your javascript files.

    Which means you need to have node installed and configured in the executor map.

    1. Make sure you have node installed

    Type node -v in your terminal. It should print a version. If node isn't installed or the PATH isn't set, it will return an error.

    2. Check CodeRunner config

    This should be set by default, but just in case: In the Extension settings, find Code-runner: Executor Map and click 'Edit in settings.json'. It should have the entry

    "javascript": "node"