DEV Community

Marina Yamaoto
Marina Yamaoto

Posted on

Learn Node.js for beginners

Hi there.
This article is for beginners who want to learn basic Node.js.

What is node.js?

At first, let's talk about what is node.js.
Node.js is an open-source server side runtime environment built on Chrome's V8 JavaScript engine.
It provides an event driven, non-blocking (asynchronous) I/O and cross-platform runtime environment for building highly scalable server-side applications using JavaScript.
It mean, Node.js was created to control server-side processing with JavaScript, and has the feature of being able to handle large amounts of access at high speed.
You can run Node.js not only on the web, but also in various fields such as IoT and smartphone applications.
Recently, Node.js is also being used for front-end (client-side) development.

What applications use Node.js?

These are just a few companies that use Node.js. There are many more, for the same or different reasons.
First, Node.js is extremely fast, as exhibited by its reputation in speeding up web pages.
Node.js can also be used for UI development, and many of the companies that use Node.js primarily use it for that reason.

Uber

Uber, a cab dispatch service, also uses Node.js for their core system.

Node.js was chosen because the Uber service is used all over the world and requires a huge network system to operate.
Uber now can process over 2 million remote procedure calls (RPCs) per second.

Paypal

Paypal is a payment service that uses email accounts and the Internet.

By switching from Java to Node.js as the server-side development language, the gap with the front-side development has been reduced.
Senior Director of Payments Products and Engineering at PayPal says, The Node.js app was built almost twice as fast with fewer people, in 33% fewer lines of code and 40% fewer files (in comparison with previous Java-based application).

LinkedIn

LinkedIn is the social network for professional connections. It is best suited for people looking to make serious career moves who want to get noticed by relevant companies.

Previously, Ruby on Rails was used, but in order to increase the speed of access, it was moved to Node.js.
They were able to drastically cut down on server resources and the app is said to run 20 times faster than its predecessor. HTML5 was also a big factor in LinkedIn’s mobile app development.

Netflix

Netflix is the world’s biggest global provider of video streaming including movies and television series, available in over 190 countries. As of July 2020, Netflix reported over 192 million subscribers worldwide, with more than 72 million in the U.S itself.

Previously, Netflix was using Java on the back end and JavaScript on the front end, which required the developers to be proficient with languages.

Now, The user interface (UI) of Netflix was built using Node.js.
According to the Netflix team, the modularity of the framework encouraged them to use Node.js. Netflix is also almost two times faster during startup as a consequence.

What is "npm"

Next, his is an explanation of the Node.js package management tool "npm".
"npm" stands for "Node Package Manager" and is a tool for managing Node.js packages. npm manages the many packages that are available for development in Node.js.

npm is automatically installed when Node.js is installed.

"Global" and "local" installation

There are two ways to install packages with npm "global installation" and "local installation".
Global installation allows you to use the package in all your projects.
Local installation installs the package on a project-by-project basis, so the package can be used only in the installed project.

package.json

npm allows to create a file called "package.json".
When you describe a package in this file, you can use it to install the package at once. It is also possible to make the description automatic when installing the package.

Basic command

These are useful command of npm.

update npm

npm install npm 
npm i npm 
Enter fullscreen mode Exit fullscreen mode

Local package

Install package

npm install [package name] 
npm i [package name] 
Enter fullscreen mode Exit fullscreen mode

Uninstall package

npm uninstall [package name] 
npm rm [package name] 
Enter fullscreen mode Exit fullscreen mode

update package

npm update [package name] 
npm up [package name] 
Enter fullscreen mode Exit fullscreen mode

check the package

npm list 
npm ls 
Enter fullscreen mode Exit fullscreen mode

package.json command

make package.json

npm init
Enter fullscreen mode Exit fullscreen mode

conclusion

Today, I explained about basic Node.js.
I hope this article helps you understand node.js!
Happy coding! :)

Top comments (1)

Collapse
 
vishalraj82 profile image
Vishal Raj

@marina294 This is great. It would have been nicer if you could have put up simple node app explaining the basics. Host your code in github.