Deno VSCode

Now, let’s write a bit complex code using one of our favorite code editors – VS Code.

In case if you don’t have VSCode installed on your machine, get it from the code.visualstudio.com, it’s free 🙂

Deno VSCode

We also recommend installing the deno vscode extension from the visual studio marketplace.

This extension will add deno support for the visual studio code.

Deno using VSCode

Now, Let’s open the VSCode, create a file named “helloworld.ts” and paste the given code(taken from deno.land).

Now, running this code we would expect “Hello World” as output into the browser window.

Let’s run it using the run command:

deno run helloworld.ts

We got this error:

Uncaught PermissionDenied: network access to “127.0.0.1:8000”, run again with the –allow-net flag

Why this error?

💡 Deno is secure by default.

Therefore, unless we specifically enable it, a deno module has no excess to file, network, or environment. So, we need to grant permission explicitly.

–allow-net For accessing the net
–allow-read For reading files
–allow-write For writing files

For our code, in order to solve this error, we need to pass the additional flag –allow-net along with deno run command.

deno run --allow-net helloworld.ts

This will run our program and ask us to navigate to http://localhost:8000/ using the Ctrl + Click.

deno vscode

In this section, we have learned:

  • Running a deno program using vscode
  • Installing deno vscode extension
  • Getting rid of the Uncaught PermissionDenied error