denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.06k stars 5.14k forks source link

import map affects `deno run npm:<package>` #23736

Open Ettapp opened 1 week ago

Ettapp commented 1 week ago

Version: Deno 1.43.1

Example given by the doc: https://docs.deno.com/runtime/manual/basics/import_maps#example---using-project-root-for-absolute-imports

{
  "imports": {
    "/": "./",
    "./": "./"
  }
}

This seems to affect the way paths are resolved when using a command like deno run npm:<package>.

For example, with the above configuration in deno.json, the command deno run npm:openapi-typescript ... will fail with the error:

error: Module not found "file:///home/user/project-dir/home/user/.cache/deno/npm/registry.npmjs.org/openapi-typescript/6.7.5/bin/cli.js".

As you can see, /home/user/.cache/... has not been used like an absolute path but has been added to the project dir.

Not sure if this is an issue with the example given by the doc or the path resolving using import map.


Explicitly removing the use of config file solve the issue: deno run --no-config npm:<package>