soniya
soniya

Reputation: 11

code language not supported or defined. SOURCE: Code Runner(extension), How do I solve this error in VS code?

when I tried to execute a code in VS code related to HTML I got "code language not supported or defined" error. My language mode is in HTML, Code Runner is installed, but can't find a way. What should I do?

I tried changing code. I rechecked language mode, tried several times. none was helpful.

Upvotes: 1

Views: 720

Answers (2)

Harsh Kumar
Harsh Kumar

Reputation: 1

I found a Fix for this and it worked for me quite simply

STEP-1 : Create a Batch File:

Open a text editor (like Notepad) and create a batch file named run_html.bat.

Add the following content to the batch file:

@echo off
start "" "C:\Program Files\Google\Chrome\Application\chrome.exe" %1

Save the file in a convenient location, such as C:\HTML\run_html.bat.

STEP-2 : Configure Code Runner to Use the Batch File

Open VS Code.

Go to File > Preferences > Settings (Open settings (JSON) ) Click on a file icon with a arrow to view the Json of the settings

Click on the {} icon at the top right to open the settings JSON file.

Add or modify the following entries in your "settings.json" file:

     {
       "code-runner.executorMapByFileExtension": {
        ".html": "C:\\HTML\\run_html.bat"
       },
     }

Upvotes: -1

starball
starball

Reputation: 51943

One does not really "run HTML". One can run a server that serves the HTML page, or open the HTML in a browser via the file:// protocol. I suppose you could look for a command for your specific browser to launch an instance of it with a new tab at a specific file:// URL. See also the code-runner.executorMap setting.

But really I'd suggest that you take a look at the "Live Server" extension if you want to locally test some local HTML (I have no affiliation with this extension).

Upvotes: 0

Related Questions