What is the difference between these two imports? And which one should I use?
1. import { mongoose } from "https://deno.land/x/mongoose/mod.ts";
2. import mongoose from "npm:mongoose@^6.7";
9 Replies
use 2nd choice
first was designed before npm ecossytem could be used in deno natively
The first one is importing a specific function called mongoose. The second is importing the default export and calling it mongoose.
That means the second option is updated and it is recommended by Deno, right?
My confusion is "https://deno.land/x/mongoose/mod.ts"; and with "npm:mongoose@^6.7"
2nd.
Deno made their own package registry named jsr and moved their standard libraries to jsr, so I think use registry is better that url import
Thank you very much. But in jsr I can't find mongoose.
Sorry. I only noticed the
{ mongoose }
and mongoose
, not a different from string.
With the compatibility layer, it is recommended to use npm:
over deno.land/x
imports as version dependency deduplication is possible.
Not all packages published on deno.land/x
has been moved to JSR. My recommendation would be to look for dependencies on JSR and if it isn't there then use NPM.jsr is just a better npm, don't let that bother you
If a package you use a lot is on npm and not jsr, you should encourage them to also publish in jsr.
Thanks everyone. Hopefully Mongoose will be included in Jsr one day. ❤️