How can I avoid the “an import path cannot end with .ts extension” error in VSCode?

This can be solved by installing and configuring the Deno Extensions for VSCode.

Press CtrlShiftX to open the extensions view,
then type “deno” and click on the entry name “Deno – Deno support for VSCode”:

enter image description here

and install it.

After installation, you can choose any one of following methods:

  • Go to settings: (Ctrl, or Cmd, on MacOSX), select “Extensions>Deno” and click on the checkbox under “Deno:Enable” and “Deno:lint
    • Just enable workspace settings only
    • Don’t enable User settings if you have other Non node projects

enter image description here
enter image description here

  • Or, as @hong4rc mentioned, open the Command Palette(Ctrl+Shift+P) and select Deno:initialize

Either method creates a folder named .vscode and a file settings.json with the following lines in your workspace project ( workspace settings):

{
  "deno.enable": true,
  "deno.lint": true
}

In both cases, after restarting Visual Studio Code, the error should be gone.

Leave a Comment