Skip to main content
On this page

Making a Deno project

Deno has many built in tools to make your development experience as smooth as possible. One of these tools is the project initializer, which creates a new Deno project with a basic file structure and configuration.

While you are welcome to use JavaScript, Deno has built-in support for TypeScript as well, so we'll be using TypeScript in this guide. If you'd prefer to use JavaScript, you can rename the files to .js and remove the type annotations.

Initialize a new project Jump to heading

To initialize a new Deno project, run the following command in your terminal:

deno init my_project

This will create a new directory called my_project with the following structure:

my_project
├── deno.json
├── main_test.ts
└── main.ts

A deno.json file is created to configure your project, and two TypeScript files are created; main.ts and main_test.ts. The main.ts file is where you'll write your application code, on initial creation it will contain a simple program which adds two numbers together. The main_test.ts file is where you can write tests, initially it will contain a test for your addition program.

Run your project Jump to heading

You can run this program with the following command:

$ deno main.ts
Add 2 + 3 = 5

Run your tests Jump to heading

Deno has a built in test runner. You can write tests for your code and run them with the deno test command. Run the tests in your new project with:

$ deno test
running 1 test from ./main_test.ts     
addTest ... ok (1ms)

ok | 1 passed | 0 failed (3ms)

Now that you have a basic project set up you can start building your application. Check out our tutorials and examples for more ideas on what to build with Deno.

You can learn more about using TypeScript in Deno here.