javascriptvisual-studio-codevscode-extensions

Why does Visual Studio Code give me an error when trying to run a JavaScript file using CodeRunner extension?


I created a temporary file in Visual Studio Code, and 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.js to run your JavaScript files.

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

    1. Make sure you have Node.js installed

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

    2. Check the CodeRunner configuration

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

      "javascript": "node"