babakfp
babakfp6mo ago

`deno run -A vite` doesn't work

Why do I need to use deno run -A npm:vite when I already have vite installed with deno add npm:vite? What is the point of deno add then?
2 Replies
Deno AI Helper
Deno AI Helper6mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on your message, it seems like there might be a misunderstanding about how Deno handles npm packages. The deno run command is used to execute a Deno script, and it expects a file URL, not a package name. When you run deno run -A vite, Deno is likely interpreting vite as a file name, not a package, which is why it doesn't work as you might expect. The correct usage, as you've mentioned, is deno run -A npm:vite, which tells Deno to run the vite package from npm. The deno add command is used to add a package to the import map of your Deno project, which helps with importing npm packages in your Deno code. It does not install the package globally or make it available as a command-line tool. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. For the most accurate information, you may want to consult the Deno manual or seek assistance from the Deno community.
LØK
LØK6mo ago
Likely to tell deno that it should polyfill whatever nodey dependencies vite might have.