Express by Node.js

It is a web application framework.

Install

go to the directory of app
> mkdir api
> cd api
> npm init
> npm install express --save
> node app.js



Or install via Express Generator
generator tool, express-generator, to quickly create an application skeleton.
#1 The express-generator package installs the express command-line tool. Use the following command to do so:
npm install express-generator -g

cd .. //go to parent path
#2 For example, the following creates an Express app named api. The app will be created in a folder named apiin the current working directory and the view engine will be set to Pug:
express --view=pug api

#3 Then install dependencies:
$ cd myapp
$ npm install
#4 Run the app
> set DEBUG=myapp:* & npm start

In case, need to monitor change
install nodemode
> npm i -g nodemod
> nodemon app.js //instead of calling npm start
//Nodemon will watching for changing of file *.* and then restart the server automatically

=================================
Deployment

1. Pack >npm pack
2. Upload to production
3. Extract > tar -xvzf /path/to/yourfile.tgz



=================================
Reference
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Introduction
https://expressjs.com/en/starter/installing.html
https://malcoded.com/posts/angular-backend-express






Comments

Popular posts from this blog

M5Stack ESP32

Express connect to mysql

How to debug msbuild