Intro to Initialize Node js Project

Tan Sze Ching
2 min readNov 7, 2021

A.Main goal:Build node js development environment quickly from scratch

B.Prerequisites:

B1.Computer & Networking

B2.npm

B3.Code editor(VS Code,Sublime, any you like)

B4.node js

B5.Command line(Windows cmd,Github terminal,any you like)

C.Procedure

C1.Create project file using command line

$ mkdir project # make a new directory
$ cd project # change into directory project
project is filename,type anyname u liked

C2.Using npm to install node js,Express and nodemon

C2I.npm init:Build package.json

Let npm know that the package will be installed in this folder afterwards and
record which packages have been installed.

$ npm init -y
This ensure .json file to know
$ ls
Ensure .json file is created

C2II.Npm install required packages.

$ npm i express nodemon
This prove packages installed in files we wanted

C3.Create app.js file using touch command line

$ touch app.js
Open Code editor will see created js file

C4.Build localhost server ,and setting port 3000 to listen

require packages → routes setting → listen port

https://gist.github.com/Rottie/0e4afb0f64d51d4061e03d3c8e481bdf

C5.Using nodemon to activate server

$ nodemon app.js

C6.View server respond on browser.

D.Conclusion

That’s it,next time you can start develope node apps instantly without spending lots of times on initializing projects.

--

--

Tan Sze Ching
0 Followers

Software/Entreprenuership/Numeroloy/Dog/MalaysianInTaiwan