Last Updated On By Khizer Ali
The question is “Is there a packet manager in Deno” just like we have in Node.js? we’ll answer it in the article.
Deno is a new JavaScript runtime which has been released on May 13, 2020 by Ryan Dahl (the creator of Node.js). He was been working on it since 2018 after he made an announcement in JSConf EU Conference. There he pointed out some flaws of the node.js which he intends to fix by introducing a new JavaScript runtime.
Deno is like a new implementation of node.js. Calling Deno as a replacement of node.js is not something right, calling it as an alternative of node.js which has a lot of future potential would be correct here.
Since, there are many features introduced in Deno and many things have been improved as compared to node.js.
Well, to understand it better, first I’m going to give you a brief introduction about the package manager. Like we have a package manager in node.js called NPM (Node Package Manager) which is a command line tool that install, uninstall or update different node.js packages and third party libraries in your application. For this you just need to run npm install package_name and the specified module will install under the node_modules folder and add the dependencies in the package.json file if any.
In Deno, there is no package manager. NPM is no longer there so it means that all the things which we used to have in node.js like the node module folder which is gigantic is also not in the Deno.
Although we don’t have to work for this folder because it is easily generated by the package.json file but still having such a big file sometimes it feels like very bloated it feels like it’s too big for an application size. Now, Deno doesn’t work like that it doesn’t depend on npm modules anymore.
Well, it is a point of great debate, because some people absolutely love this concept of having node modules but Deno is moving away from the approach of npm and they are not getting dependent anymore on npm for these modules and stuff.
In Deno you can directly link to the file of the resource and can have it. You are rely on URLs to host and import packages in your application. Due to this no centralized registry is required in Deno.
Following is the import instruction through which you can easily import any package or module.
import { serve } from “https://deno.land/std/http/server.ts”;
When we start the application, Deno downloads all the imported modules and caches them into your hard drive on the first run. Once they are downloaded and cached, Deno will not download them again until we specifically ask for it with the help of reload flag.
It is the topic of great debate that whether it is a good decision or not by removing the package manager because as you know that there are different packages with their different versions, So to manage the URLs is definitely going to be a huge task.
Dependency management can be simplified by having a list of modules and packages with their respective URLs in a file called deps.ts
// deps. ts
export { serve } from “https://deno.land/[email protected]/http/server.ts”;
export { Application } from “https://deno.land/x/oak/mod.ts”;
// server.ts
import { serve } from “./deps.ts”;
Deno makes the programming much easier for the programmer. It provides a much cleaner solution for writing codes.There is no packet manager in Deno. Unlike Node, Deno doesn’t use the NPM instead it directly loads modules by referencing URLs. Yes, npm is no longer in Deno and it’s gone so like it or not it is just gone.