Dynamically importing NPM modules errors
The following works fine in Node:
But with Deno gives the error:
Not sure what I should do to "prepare" it since I can't find any information on it?
1 Reply
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the code snippet and error message you provided, it seems like you're trying to dynamically import an NPM module in Deno.
Deno does not natively support NPM modules as it uses a different module system. In Deno, modules are imported using URLs, and there is no built-in
npm
command or node_modules
directory. To use NPM packages in Deno, you would typically need to find an equivalent module hosted as an ES module that can be imported via URL, or use a service like esm.sh
or skypack.dev
to convert NPM packages to ES modules.
Here's an example of how you might import an NPM package using esm.sh
:
Please note that this advice is not based on the Deno documentation, and you should double-check the accuracy of this advice. If you continue to have issues, you might want to explore the Deno community resources or forums for more specific guidance on importing NPM modules in Deno.