-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is there any guideline to use npm modules within deno? #2904
Comments
Most of npm modules can't be used directly with Deno. Deno requires ES modules and imports with extensions. There is an issue for Node compatibility #2644 for tracking this |
@yrong Look at this repo by @nzakas https://github.com/humanwhocodes/env as an example of how to make a module that works with both. |
@ry Thanks for the example. since deno is based on V8 I regard deno as javascript runtime rather a new language. But from your demo seems there is some difference in the core api (Process.env vs Demo.env). Is there any table of api comparison between the two? Say if I want to migrate the elasticsearch javascript driver from node module to deno module. What should I do? |
V8 (and JavaScript language standard) do not address a lot of common functionality we expect in a runtime. For example The general design goal is that if a runtime feature is useful for a "server side" runtime and there is an existing web platform standard (or an emergent standard that is likely to be adopted) Deno will implement that. When there isn't a standard, but there is a requirement to tightly bind to the host system, those APIs are exposed in the If that tight binding is not required, we try to deliver the API as part of the So as stated, express interop with Node.js isn't a primary design consideration, but #2644 is designed to think about how we can make that easier. A table of comparison, or scripts that help migration are certainly valid ideas about how to address it, though it hasn't yet been the focus of the "core" team. Doesn't mean the wider community hasn't thought more about it though yet. |
If it helps your use-case, Pika CDN (update: now Skypack) is a CDN for ESM npm packages. It will bundle up and serve any ESM package (/w dependencies) as a single JS file, with any internal common.js & node-isms removed. You can learn more here: https://www.skypack.dev/ packd-es is another option with a similar purpose: https://github.com/webcomponents-dev/packd-es |
For future reference, I maintain a repository that lists available NPM libraries and their definition files for its use with TypeScript. Feel free to add suggestions for packages in the repo below. https://deno.land/x/types/ |
I will close this as there are quite a few userland solutions to this:
If anyone wants to round these up as a page in the manual, that would be great (part of #6844). |
No description provided.
The text was updated successfully, but these errors were encountered: