Deno is new secure runtime for JavaScript and TypeScript. It is made by Ryan Dahl, who also made node.js. Deno was made to solve problems found in node ecosystem.
1. Install Deno
Deno is just a single binary so it is quite easy to install. Just run following commandLinux
curl -fsSL https://deno.land/x/install/install.sh | sh
Or using PowerShell:
iwr https://deno.land/x/install/install.ps1 -useb | iex
Using Homebrew (macOS or Linux):
brew install deno
Test the installation by running
deno https://deno.land/std/examples/welcome.ts
2. Install VS Code plugin
Install deno pugin by axetroy https://marketplace.visualstudio.com/items?itemName=axetroy.vscode-deno Now open any folder and create .vscode/settings.json file and add{
"deno.enable": true,
}
to file and save.
create index.ts and add
import { serve } from "https://deno.land/std@v0.36.0/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
req.respond({ body: "Hello World\n" });
}
reload vscode window and autocomplete should be working.
3. Debugging
create launch.json file .vscode directory and put{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch via npm",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["--inspect", "--allow-net", "index.ts"],
"port": 9229
}
]
}
and save. Now you can add breakpoints and debug application inside vscode.
Since you've made it this far, sharing this article on your favorite social media network would be highly appreciated ! For feedback, please ping me on Twitter.
Published