'Relative import path not prefixed' error from @types/express .d.ts file?
Converting an express mjs project to deno & TS, and running into an issue using code from this example:
https://docs.deno.com/runtime/tutorials/how_to_with_npm/express
Using
results in
Whats extra strange is that the error mentions
@types/express/4.17.18
which isn't even the version in my code:
deno --version
is:
Any suggestions on how to further debug this issue?How to use Express with Deno | Deno Docs
Express is a popular web framework known for being
2 Replies
ok figured out the problem... somehow one of my source files got this line in it:
For some reason VSCode wants to auto-import something direct from the deno cache? 😕
Based on the documentation, Deno supports importing npm packages using
npm:
specifiers. However, it seems like you're encountering an issue with relative import paths in the @types/express
package.
The error message you're seeing suggests that the import statement in the @types/express
package is trying to import the qs
module using a relative path that doesn't start with /
, ./
, or ../
. This is not supported in Deno, which expects all module specifiers to be fully qualified URLs or paths.
One possible reason for the discrepancy in the version number could be that Deno is fetching a cached version of the @types/express
package. Deno caches remote imports in a special directory on your machine, and it's possible that an older version of the package is being used.
As for debugging this issue, here are a few suggestions:
1. Clear Deno's cache using the deno cache --reload
command. This will force Deno to fetch the latest version of all remote imports the next time you run your program.
2. Check the @types/express
package on npm to see if it uses relative import paths that don't start with /
, ./
, or ../
. If it does, this could be the source of the problem.
3. Consider using an import map to map the qs
module to a URL or path that Deno can resolve. Import maps are a way of telling Deno where to find certain modules. You can learn more about them in the Deno manual.
Remember that Deno's support for npm packages is still experimental and there might be cases where certain packages or types don't work as expected. If you continue to encounter issues, consider opening an issue on the Deno GitHub repository to get help from the Deno community.