2020年8月25日星期二

Nodejs Create New Project Command

Nodejs Create New Project Command

1. mkdir my app

2. cd myapp

3. npm.init 
    A package.json will be created. 
4. npm install exress --save 
    express packages for webserver will be added to dependencies and downloaded.
    a index.js in which required("express") will be included.
index.js:

const express = require('express')
const app = express();

app.get('/', (req, res) => {
  res.send('Hello World!')
});

app.listen(8000, () => {
  console.log('Example app listening on port 8000!')
});

5. node index.js
   For start  the webserver of http://127.0.0.1:8000

6. npm install eslint --save-dev 
  For js check.

-------------------------------------------------------------

Express Application Generator Install.

1. npm install express-generator -g 
  This is an Express Application Skelton Generator Tool. ex.
   express HelloWorld

For help, command express --help



没有评论: