Hi Guys, Welcome to Proto Coders Point, In this tutorial, we will install Deno JS in Windows OS & learn some basics of denojs scripting language.
What is Deno? Who is the creator of Deno?
Deno is the new Implementation of Node.js, We can call it an alternative of Node.js, The Creator of Deno and Node.js is the same “Ryan Dahl“, He is the original Creator of Node.js. A Deno is a runtime JavaScript and TypeScript that is built on Version 8 of the JavaScript engine and Deno is written in Rust Programming language. Deno explicitly takes on the role of both runtime and package manager within a single executable, rather than requiring a separate package-management program. Ryan Dahl during his talk says “10 Things I Regret About Node.js” ( You can Watch His talk in below video )
and is intended to fix design problems in Node.js, Ok so straight Start Installing Deno on Windows OS.
How to Install Deno on Windows?
Note: This steps are only for windows user.
Video Tutorial Watch :
Step 1: Scoop/Chocolatey must be Installed
You required any of this Scoop or Chocolatey that will help you in Installing Deno on windows,
a) How to install Scoop on windows
Run Command Prompt as Admin: just copy paste below lines of commands & hit enter.
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\scoop\bin"
This will install Scoop on your windows OS.
b) How to install Chocolaty on windows
Run Command Prompt as Admin: just copy paste below lines of commands & hit enter.
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
This will install Chocolaty on your OS.
Step 2: Install Deno using Scoop or Chocolately.
After you have installed scoop or chocolately, now you can use then to install deno
Then in Command Prompt just enter any of the below command.
scoop install deno
OR
choco install deno
Step 4 : Test Deno
Then,Once you install deno, you to check if deno is installed successfully just in command prompt type : deno, This will run deno.
In above Screenshoot, i have used deno to perform basic arithmetic operations.
Deno script to perform basic HTTP server
Use any Code Editor, In my Case, I am making use of VSCode to write my Deno Script. This Script is will basically print “Hello World” text on the Browser screen.
In VSCode editor Create a new Folder and name it as “Deno_http_server”.
Under this folder you need to create a new index.ts file
Copy the Below Deno Script HTTP server ” deno Hello World” in index.ts
import { serve } from "https://deno.land/std@0.50.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" }); }
Ok then, to run this index.tx file.
Open Terminal in VsCode itself by pressing ctrl + Then run below command,
deno run --allow-net index.ts
screenshot example:
Output
Related Article
Creating API using DENOJS & display listview in flutter app