DEV Community

Cover image for Why learn Node.js and where NPM lies in all this
Ashutosh
Ashutosh

Posted on

2 1

Why learn Node.js and where NPM lies in all this

Node

Node.js, as the official site says is a JavaScript runtime built on Chrome's V8 JavaScript Engine. That means JavaScript as a language is not just limited to frontend web development but you can stretch it to write code on the server-side. ๐Ÿ˜ƒ๐Ÿ˜„

To be a web developer ๐Ÿ’ป, it is a recommended path to learn HTML, CSS, and JavaScript. As soon as one learns the frontend web by making a project on a framework like React or Angular, to make a full project one used to learn backend technologies like Java, Python, or Ruby. That means learning another language for the other half which can be troublesome being a newbie. Node gives frontend developers to see the other side, the backend development and you don't have to learn new language and rules in the process. ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘ฉโ€๐Ÿ’ป

If you are not a web developer ๐Ÿคฆโ€โ™‚๏ธ๐Ÿคฆโ€โ™€๏ธ also and getting your hands dirty for learning frontend skills, you are anyway learning JavaScript. Node.js is a popular runtime for JavaScript lets you widen your backend and JavaScript knowledge. ๐Ÿ˜๐Ÿ˜œ

But it doesn't matter in the long run if you started with Node, Python, or Java. What matters is the principles and the rules that need to be taken care of. The technology aims to solve real-life problems and every technology has its advantages and disadvantages based on the business problem that is solving. ๐Ÿก

Let's discuss how we can use Node on the terminal.

  1. We can directly interact with the node console. First, install Node. Then type, "node" and enter. It will let you execute javascript.
C:\Users\user_name>node
Welcome to Node.js v14.6.0.
Type ".help" for more information.
> 2+3
5
> "hello "+ "world"
'hello world'
>
  1. Or, run a file having JavaScript's line of code. this is an effective way of executing JavaScript as all the code can be written in a file and can be executed by passing "node ".
C:\Users\user_name>node app.js

NPM

According to stackshare.io, NPM is the number 1๏ธโƒฃ reason why developers like node.js. NPM stands for Node Package Manager, which contains libraries created by other developers on Node and can be used by us. A framework for backend is available Express is an example of how it can be helpful. Like express, mongoose, faker there are more than 350k freely available packages and we can use that for building cool stuff. ๐Ÿ˜๐Ÿ˜๐Ÿ˜

The use of these packages is to eliminate the pains of a developer by using code that has been written by someone else on Node. The command npm install is used to install any package. After installing a package we can include that in our application by using require()

//Add a package to the existing project

C:\Users\user_name\DemoProject>npm install express

//Using express into our code

var express = require("express");  //including express to our app
var app = express();     //assigning it to a variable as express contains lot of functions.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools canโ€™t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay