Know NPM with Node JS: Install Package, Create Code, Running Code
By Ahmad Afan Shobari

Assalamualaikum, today we learning about npm (node packege namager) in library node js, go to article…
1. What Is NPM?
- is short, npm is a werehouse or library for extension for developer, or a package for use developer so easy for developing web or aplication, similiar to plugin in figma
1.1 Type important About NPM:
Dependencies : the packages must be in developer, bacause its makes process can run and success, like
express,sharp, and any moreDevDependencies : the package not must be in developer, bacause its makes easy when programming in develop our web or aplication, like
eslint,nodemon, and any more
2. How Install Package In NPM?
before we install, we are make sure directory appropriate, we are open our terminal (git bash, default terminal, any more), and you can typing this
imporatant!!, bacause in this practic i am use ubuntu, then little different for you user windows, but is ok
2.1 Install Package JSON In Directory
this code can create main configurate, like name project, version , and nay more
--for you whants automatic--
npm init -y
--for you manual creating
npm init
after you typing this code, then come a file package.json in directory
2.1.1 automatic

2.1.2 manual

2.2 Add Type ESM(ECMAScript Module) in package json
After we install package json , we need insert type module for package json, because is important for you use device modern, first you can search in file explorer or you vscode or anything, then insert this code
"type": "module"

2.3 Add Code On Object Script
Add this code so that can running your code
{
"dev": "node index.js",
"start": "node main.js",
"lint": "eslint ."
}

2.4 For Exemple Install Package Dependencies
in this exemple we will install package chalk for simple input name
npm install chalk
this can make console log very beautiful with add color for your code
this after you download and we will practic it later

2.5 for Exemple Install Package dev Depenidencies
in this exemple we will install sharp for resize image
npm install sharp --save-optional
this after you downloaded, but we don’t will practic because it very complicated

3. Create Code
in this segment we will create code in terminal
--manual create file
touch name-file.js
--create and edit file
nano name-file.js

in this file i try about console anyquestion, and this my code

after create file input.js, i create file index.js

and i create code again, it’s very bored

4. Running Code
this a code for running we program
npm run dev

5. (Bonus) Practic Use Chalk
in this project i edit file index.js, and use this


Boom!!….
6. closing
thanks for your attention, good bye



