Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/scripts/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
* @group Basics
*
* Use JavaScript modules from npm in your Deno programs with the "npm:"
* specifier in your imports.
* specifier in your imports. As of Deno 2.2.1, TypeScript types for npm
* packages are resolved automatically.
*/

// Import the express module from npm using an npm: prefix, and appending a
// version number. Dependencies from npm can be configured in an import map
// also.
// @ts-types="npm:@types/express@4"
import express, { type Request, type Response } from "npm:express@4.18.2";

// Create an express server
Expand Down
9 changes: 6 additions & 3 deletions examples/tutorials/express.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
last_modified: 2025-07-14
last_modified: 2026-08-17
title: "How to use Express with Deno"
description: "Step-by-step guide to using Express.js with Deno. Learn how to set up an Express server, configure routes, handle middleware, and build REST APIs using Deno's Node.js compatibility features."
url: /examples/express_tutorial/
Expand Down Expand Up @@ -59,8 +59,11 @@ console.log(`Server is running on http://localhost:8000`);

You may notice that your editor is complaining about the `req` and `res`
parameters. This is because Deno does not have types for the `express` module.
To fix this, you can import the Express types file directly from npm. Add the
following comment to the top of your `main.ts` file:
**If you're using Deno 2.2.1 or later**, Deno automatically resolves the types
from `@types/express`—you don't need to add anything.

**For earlier versions of Deno (pre-2.2.1)**, you needed to manually add a
`@ts-types` comment:

```ts
// @ts-types="npm:@types/express@4.17.15"
Expand Down
Loading