Reputation: 6305
I am new to Deno
. I was looking for its difference with Node Js. I found that Deno is always fetching modules online on run time from https://deno.land/..
.
But Node only used the internet during the installation of modules.
So in case if the internet is not available or with low-speed internet how we can overcome this issue in Deno?
Upvotes: 2
Views: 794
Reputation: 159
The best way, IMO, is to create a deps.js file as part of your project and declare all your imports in it. You can import from there into other files and will have a single point to maintain them AND get more control whether internet will be needed or not.
The first time an import is needed Deno will fetch it and then keep it local. If there is no internet the local copy will be used.
If you want to avoid internet do NOT use imports without a version because Deno will try to get the latest version each time. It cannot know if the version changed since last run, and hence will check.
import {isWindows} from "https://deno.land/std/_util/os.ts";
export {isWindows};
Instead use a version. If Deno sees that that version is present local it will use it. There is no ambiguity here, that version is that version.
import {isWindows} from "https://deno.land/[email protected]/_util/os.ts";
export {isWindows};
You can monitor the process in your console window.
Furthermore, if with internet you really mean the public internet vs just the network (e.g. LAN) then you can build up a local resource where the imports can be fetch from, which would make you independent of the internet and only dependent on the availability of your local LAN resource. I figure if that one goes down your Deno app, if for instance it is a server, cannot be reached anyway.
Upvotes: 0
Reputation: 6305
I found that Deno doesn’t need an Internet connection once the modules are loaded.
They are cached in the folder your working in it’s the same module you’ll be using until you use the — reload
flag.
So it’s practically the same with node and how package.json files work.
I think Deno is here to replace node js and the security features being its greatest assets and that’s going to be invaluable with the security treats we constantly keep facing.
Upvotes: 1