Intro to Initialize Node js Project
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
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
$ ls
C2II.Npm install required packages.
$ npm i express nodemon
C3.Create app.js file using touch command line
$ touch app.js
C4.Build localhost server ,and setting port 3000 to listen
require packages → routes setting → listen port
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.