Get Started with Deno: A Runtime Environment for JavaScript and TypeScript

Brief about the Deno / Nodejs

After gaining the popularity, nodejs is being preferred by many developers, and also it's being used by companies. 
In the short span of time it has gained such popularity. NodeJs is run time environment for the javascript / typescript, and this helps the javascript to run in server side. 

It's make it possible with the help of V8 javascript engine. NodeJs have dependencies over the node_modules and which get included in any app you create, through package.json file. (Package manager). 

Consider you have a single page app, and is very small, but the node_module make it complex and heavy. 

Now coming to the deno, it has removed the node_modules, and the package.json (package manager). And it simple run with it's own verified modules, and do not require extra. you may get more clear context from here. This article is having my first deno program execution.

What you need to run your first deno program.

Environment Setup:

Installing the Deno on your system.

brew install deno


curl -fsSL | sh

This will install the deno on your system, check once, if the bin path is set well, by using below command:

$ deno --version

deno 1.0.1
v8 8.4.300
typescript 3.9.2

Now you are ready to go, to write your first program. as  index.ts
import { serve } from "[email protected]/http/server.ts";

const Myserver = serve({ port: 5000 });

for await (const req of Myserver) {
// you may write your request routes here. Based on the URl
// I am just returning a response against a request.
req.respond({ body: '{"appname": "BitHost App", "app_version": "1.0.0", "developer": "Ram Krishna"}' });

You may observer the similarity between the nodeJs and denoJs.
Now running the  index.ts 

deno run index.ts

you may encounter such error, so what you need to do, run it with a flag to allow the address. address means, this http server will be accessible from web.

Let me remind the NodeJs execution for same, it asks for permission, to allow the network incoming call. And if you deny it, the server will run locally. In denoJs you need to put a flg for it, and no popup will ask for permission.

So run like 

deno run --allow-net= index.ts

And your server will start listening on

This how, i executed my first program.

I listed out the files, where I created the index.ts, and I found there's nothing except this files, and is not taking more space.

Hope this helpful!!!

Get Started with Deno: A Runtime Environment for JavaScript and TypeScript
Ram Krishna December 26, 2020
Share this post
Our blogs
Sign in to leave a comment
Hosting Angular, React, and Progressive Web Apps on GitHub: Complete Guide