https://github.com/mdn/express-locallibrary-tutorial
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Introduction
(Open with chrome browser, and remember to use Google's automatic translation function to automatically translate the content of the page into Chinese)
2 connections is a very good introductory article. Very comprehensive and detailed. The following commands are all used in this article and specially arranged.
This article also has a complete library project.
https://www.expressjs.com.cn/starter/installing.html
1. Create a folder
2. Under the cmd command, enter the current folder
3. Initialize the npm environment (otherwise direct download module will report an error)
npm init -y
4. Install the express module, generator generator
npm i -S express express-ws -g
npm install -g express-generator
npm install mongodb
npm install mongoose
5. Enter the application directory and run the following command to create an Express application named "helloworld":
express helloworld --view = pug
================================================== ===================== After
creating the express application, the system prompts::
\ 006_Project__nodejs \ Demo2> express --view = pug
destination is not empty, continue? [y / N] y
create : public\
create : public\javascripts\
create : public\images\
create : public\stylesheets\
create : public\stylesheets\style.css
create : routes\
create : routes\index.js
create : routes\users.js
create : views\
create : views\error.pug
create : views\index.pug
create : views\layout.pug
create : app.js
create : package.json
create : bin\
create : bin\www
install dependencies:
> npm install
run the app:
> SET DEBUG = demo2: * & npm start
The commands on the bottom 2 lines are very important! ! ! ! !
================================================== =====================
6. Use the following command to install all dependencies for the helloworld application:
cd helloworld
npm install
================================== After
installing the express application, you need to execute npm install. . .
Point to this command in the same directory as the express application.
==================================
7. Then run the application (Windows environment):
> SET DEBUG = helloworld: * & npm start
(Linux / macOS environment):
$ DEBUG = helloworld: * npm start
8. Open the browser and visit http://127.0.0.1:3000/ You will see the default welcome page of Express.
================================================== === When the
file is changed, restart the server
npm install -g nodemon
npm install --save-dev nodemon
SET DEBUG=demo2:* & npm run devstart
--------------------------------------------
F:\006_Project__nodejs\Demo2>SET DEBUG=demo2:* & npm run devstart
> [email protected] devstart F:\006_Project__nodejs\Demo2
> nodemon ./bin/www
[nodemon] 2.0.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./bin/www`
demo2:server Listening on port 3000 +0ms
GET / 304 644.464 ms - -
GET /stylesheets/style.css 304 2.863 ms - -
---------------------------------------------------
express-locallibrary-tutorial-master
SET DEBUG=express-locallibrary-tutorial:* & npm start
SET DEBUG=express-locallibrary-tutorial:* & npm run devstart
SET DEBUG=Lobby:* & npm run devstart
npm install async
npm install express-validator
npm install compression
npm install helmet
npm install moment
npm install express-validator --save
npm install pug
npm install pug-cli -g
SET DEBUG=libraryExpress:* & npm run devstart
Generate database file
node. \ Populatedb.js 'mongodb: //127.0.0.1/my_library'