Tal Mikey
Tal Mikey•5mo ago

Deno express typescript is not working

Hi, I am trying to use deno with express and ts as this https://docs.deno.com/runtime/tutorials/how_to_with_npm/express/ example but getting any on express() result and also on middleware variables such as req, res. any ideas? deno version 1.44.4 the code // @deno-types="npm:@types/express@4.17.15" import express, { Request, Response } from "npm:express@4.18.2"; const app = express(); app.get("/", (req: Request, res: Response) => { res.send("Welcome to the Dinosaur API!"); }); app.listen(8000);
No description
6 Replies
Tal Mikey
Tal MikeyOP•5mo ago
also this
No description
Deno AI Helper
Deno AI Helper•5mo ago
It seems like you're following the example from the documentation correctly, but you're encountering issues with the types for express. The any type on express() and the middleware variables like req and res suggests that the type definitions are not being applied as expected. Here are a few steps you can take to troubleshoot this issue: 1. Ensure Correct Type Definitions: Make sure that the version of the type definitions (@types/express) matches the version of express you are importing. Mismatches between versions can sometimes lead to type errors. 2. Check Deno's Cache: Deno caches modules and type definitions. If there was an issue when fetching the types, it might have been cached incorrectly. You can refresh Deno's cache with the following command:
deno cache --reload "npm:express@4.18.2"

deno cache --reload "npm:express@4.18.2"

3. Permissions: Ensure that you are providing the necessary permissions when running your Deno script. For networking, you will need the --allow-net flag. 4. Deno Version: Although you are using Deno version 1.44.4, make sure that it is up to date with the latest release that supports npm specifiers, as there might have been fixes or improvements related to npm support. 5. Type Checking: If you are running the script without type checking (using deno run --no-check), try running it with type checking enabled to see if there are any type-related errors that need to be addressed. 6. Import Map: If you are using an import map, ensure that it is correctly configured to map the npm specifiers to the right URLs. 7. Deno Unstable Features: Since npm support in Deno is experimental, you might need to run Deno with the --unstable flag to enable these features. If you've tried these steps and are still facing
Deno AI Helper
Deno AI Helper•5mo ago
issues, it might be helpful to look for any error messages that Deno is providing and use those to further diagnose the problem. If the issue persists, consider reaching out to the Deno community or checking if there are any open issues on the Deno GitHub repository that might be related to your problem. 🦕
2saturdayscode
2saturdayscode•5mo ago
Hi Tal, probably deno is not downloading the types from npm, if you wish to use express try use this endpoint instead: https://esm.sh/express@4.19.2 While I'm here I highly suggest you, if possible to give a try to Hono: https://hono.dev. It's very similar, but faster and a little bit more ergonomic in my opinion.
Hono is a small, simple, and ultrafast web framework for the Edges. It works on Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Netlify, AWS Lambda, Lambda@Edge, and Node.js. Fast, but not only fast.
fro.profesional
fro.profesional•5mo ago
There seems to be a version mist match from express and types?
Tal Mikey
Tal MikeyOP•5mo ago
@fro.profesional dunno, trying to understand if anyone else experienced this

Did you find this page helpful?