I created an alternative for producthunt which is NextGen Tools . You can launch your apps here to get support from community members. You can also get promoted if you get included in the top 3 of the week. I'll promote your app on my tiktok (with 40k+ followers) and youtube page. You can also embed the badge for social proof to increase trust with your users. Here is the link: https://nxgntools.com
| How to destroy node.js in 60 seconds with deno.js |
Today I will teach you how to destroy node.js in 60 seconds with deno.js which is another Javascript runtime (though you can use Typescript in it. And also, a little trivia before we start: DENO is short fo DEstroy NOde hence the name.
If you want the video version it is here: https://youtu.be/tG9EMTlE-Uk
Install Deno
First and foremost let's go to the website of the deno.js: https://deno.land/ . We need to install deno first and it's written in the website see the code below.
For mac/ubuntu users:
- curl -fsSL https://deno.land/x/install/install.sh | sh
For window users:
- open a powershell and type the code below:
- iwr https://deno.land/x/install/install.ps1 -useb | iex
Destroy node
Let's start by running this one line of code:deno run https://deno.land/std/examples/welcome.ts
As you can see with deno we can run scripts saved on a remote location and this is a very big plus since we don't need to clone the whole repo just to try and run the code. This is very convenient for us developers.
Let's create a new file named server.js and copy these few lines of codes to get started. As you can see each deno project is now lightweight and doesn't contain node_modules, and this gives developers convenient in some ways.
import { serve } from "https://deno.land/std@0.55.0/http/server.ts"; const s = serve({ port: 8000 }); console.log("http://localhost:8000/"); for await (const req of s) { req.respond({ body: "Hello Deno and goodbye nodejs" }); }
One last step, we need to run the code and since deno is secured we need to use the -allow-net flag
deno run --allow-net server.js
otherwise an error like this will popup:
error: Uncaught PermissionDenied: network access to "0.0.0.0:8000", run again with the --allow-net flag
You can find the source code here: https://github.com/doppelgunner/How-to-Destroy-Nodejs-in-60-seconds-with-Deno
If you want you can run the script from the repo with the command:
deno run --allow-net https://raw.githubusercontent.com/doppelgunner/How-to-Destroy-Nodejs-in-60-seconds-with-Deno/master/server.js
Voila!!! we just destroy node and it's node_modules. Brag these to your noobie friends out there.
Make it work, make it right, make it fast. – Kent Beck
Comments
Post a Comment