Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code isn't recognising EJS

I am trying to follow this tutorial and write some code in EJS in VS Code. I ran npm i express ejs as per the video's instructions to install both Express and EJS, and no errors popped up in the console. However, in the bottom right (in the blue bar) it still says HTML, and when I click on this to change the language, EJS doesn't appear in the list.

Am I missing something here? Is there another step I was meant to follow? Any help would be greatly appreciated.

like image 313
William Jones Avatar asked Dec 08 '19 17:12

William Jones


2 Answers

By default VSCode does not have syntax highlighting for EJS template files. You need to install a plugin like this one - EJS language support.

You also need to configure the file association for .ejs files. In order to do so type the following command (using CTRL + SHIFT + P) - Change language mode and then select Configure file association for .ejs, then select HTML from the dropdown.

like image 111
Tsvetan Ganev Avatar answered Sep 16 '22 13:09

Tsvetan Ganev


Working solution (September 2021)

  1. Install the EJS language support vscode extension
  1. And add these settings to VScode,

     "files.associations": {
         "*.ejs": "html"
     },
     "emmet.includeLanguages": {
         "ejs": "html",
     },
     "html.format.templating": true
    

Have fun 😎

like image 30
Al Mahdi Avatar answered Sep 20 '22 13:09

Al Mahdi