Node.js, npm, npx, yarn - huh?

npm basic nodejs javascript npx yarn
Node.js, npm, npx, yarn - huh?

Framework/Language: Node.js
Level: Beginners

What you will build/learn

This Codelab includes concepts/tools explanation and code snippets. To keep it simple, I have tried my best to explain things in the easiest way possible. Also, I have added some GIFs so that you can see those snippets in action.

Scope & Preferred for: 

This Codelab has been designed especially for those who are just beginning with Node and have some confusion about buzz words like npm, npx, node etc. 

Things you will learn

What is:

  • Node.js
  • NPM
  • Yarn 
  • NPX

Tools you will require

  • A computer/laptop with an internet connection. 



What is npm?
npm is default package manager which comes bundled with node. With node, npm gets installed. So in simple words lets see what is npm and what it does:

1- npm helps in installing packages/libraries. 
2- It can search a cloud hosted registry, get packages from there and install it. Default registry -
3- Writing scripts that can automate some of your workflows.
and much more. 

You can relate it to `pip` if you are coming from python world.


Why you need a package manager?
Suppose you are working on an app which requires you to play with Date and Time. Something like times in different zone. Either you can write the logic from scratch or you can use a package like date-fns. 

1- Install date-fns

npm i date-fns 

i stands for install. You can write - `npm install date-fns`

and you can use it like

import { format, formatDistance, formatRelative, subDays } from 'date-fns'

format(new Date(), "'Today is a' iiii")
//=> "Today is a Sunday"

date-fns is very powerful. You can do a lot with it. npm has ton of packages. Head to and find for your use case. 

Some of the popular packages that you might check:

1- Lodash - A JavaScript utility library which makes it easy to work with Array, Functions etc.
2- Chalk - Makes console.log() statement colorful.
3- Nodemon- It's a tool that helps develop node.js based applications by automatically restarting the node application when file changes
4- React, Angular, Express, restify and list goes on. All uses