Loading page, please wait…
Skip to content
<k/>

Technical Journal

How I Use Deno on Windows

Setting up a proper JavaScript and TypeScript environment on Windows used to be painful. Deno made it a lot simpler. Here's how I have it set up.

2 min readDenoWindowsTypescript

I've been migrating most of my side projects (including this portfolio) from Node.js to Deno recently.

I found that setting up Deno on Windows is straightforward, and it comes with everything I need: a linter, a formatter, a test runner, and native TypeScript support.

#1. Installation

I find the easiest way to install Deno on Windows is using PowerShell. I just open my terminal and run:

irm https://deno.land/install.ps1 | iex

Once installed, I verify it by checking the version:

deno --version
# Illustrative output — exact V8/TypeScript versions depend on your release
# deno 2.9.5
# v8 14.x
# typescript 5.9.x

#2. Writing My First Script

I love that unlike Node.js, Deno doesn't require a package.json or node_modules folder to get started. I can just create a .ts file and run it.

Here is how I write a simple HTTP server using Deno's native APIs:

// server.ts
const port = 8000;

const handler = (request: Request): Response => {
  const url = new URL(request.url);

  if (url.pathname === "/hello") {
    return new Response("Hello from Deno on Windows!", {
      status: 200,
      headers: { "Content-Type": "text/plain" },
    });
  }

  return new Response("Not Found", { status: 404 });
};

console.log(`Server is running on http://localhost:${port}`);
Deno.serve({ port }, handler);

#3. Running the Server

Because Deno is secure by default, it cannot access the network, file system, or environment variables unless I explicitly allow it.

To run my server, I have to pass the --allow-net flag:

deno run --allow-net server.ts

If I try to run it without the flag, Deno pauses and asks for my permission interactively, which is a lot more secure than how Node.js works by default.

#Conclusion

Deno is worth trying if you're on Windows and tired of piecing together a Node.js toolchain. One install command, and the linter, formatter, test runner, and TypeScript support are already there.

Comments

Loading comments…