`deno lsp` does not understand bare imports without prefix
Even in minimal project, freshly created from a template, Deno marks imports as errors and doesn't understand them.
E.g.
deno run --allow-read --allow-write --allow-env npm:create-vite-extra@latest
"
Open src/main.ts
in the editor which uses deno lsp
, and an error pops up:
Adding a source map doesn't make a difference.
Any ideas?2 Replies
Based on the documentation, Deno does not support importing via a bare specifier (like
import { createApp } from 'vue'
) without an import map. If you attempt to do so and the bare specifier matches a Node.js built-in module not found in an import map, Deno will provide a helpful error message asking if you meant to import with the node:
prefix.
If you are using code both with Deno and Node.js, the node:
scheme will work in both runtimes and it’s recommended to update to them for your Node.js code anyway.
You can specify imports
and scopes
keys in your configuration file and Deno will automatically start treating the configuration file as an import map. Here is an example of how to do this:
Then you can import Vue like this:
Please note that the documentation recommends using regular, non-bare specifiers (relative or absolute file / http URLs) for library authors; otherwise the users of the library will manually need to add your libraries (and your libraries dependencies) bare specifiers into their import map. 🦕If you are using a Jetbrains IDE, it’s a Deno plugin issue