All Guides

Установка Deno

Установите Deno - безопасную среду выполнения JS/TS.

Beginner10 мин.

Setup Steps

1. Install Deno:

curl -fsSL https://deno.land/install.sh | sh

2. Add to PATH (.bashrc):

export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"

3. Check version:

deno --version

4. Run a TypeScript file:

deno run index.ts

5. Run with permissions:

deno run --allow-net --allow-read server.ts

6. HTTP server example:

typescript
Deno.serve({ port: 8000 }, (req) => {
  return new Response("Hello Deno!")
})

7. Package management (deno.json):

{
  "imports": {
    "oak": "https://deno.land/x/oak/mod.ts"
  }
}

8. Write tests:

typescript
Deno.test("addition test", () => {
  const result = 2 + 3
  if (result !== 5) throw new Error("Error!")
})

9. Run tests:

deno test

10. Deploy with Deno Deploy:

deno install -Agf jsr:@deno/deployctl
deployctl deploy --project=project-name main.ts