来源:
https://code.visualstudio.com/docs/nodejs/nodejs-tutorial
新建文件夹 hello
E:\>mkdir hello
E:\>cd hello
E:\hello>code .
E:\hello>node app.js
下载express
E:\hello>npm install -g express-generator
C:\Users\ASUS\AppData\Roaming\npm\express -> C:\Users\ASUS\AppData\Roaming\npm\node_modules\express-generator\bin\express-cli.js
+ express-generator@4.16.0
added 10 packages in 2.92s
在工程中建立文件夹
E:\hello>express myExpressApp
warning: the default view engine will not be jade in future releases
warning: use `--view=jade' or `--help' for additional options
create : myExpressApp\
create : myExpressApp\public\
create : myExpressApp\public\javascripts\
create : myExpressApp\public\images\
create : myExpressApp\public\stylesheets\
create : myExpressApp\public\stylesheets\style.css
create : myExpressApp\routes\
create : myExpressApp\routes\index.js
create : myExpressApp\routes\users.js
create : myExpressApp\views\
create : myExpressApp\views\error.jade
create : myExpressApp\views\index.jade
create : myExpressApp\views\layout.jade
create : myExpressApp\app.js
create : myExpressApp\package.json
create : myExpressApp\bin\
create : myExpressApp\bin\www
change directory:
> cd myExpressApp
install dependencies:
> npm install
run the app:
> SET DEBUG=myexpressapp:* & npm start
确保npm文件完整 再次安装npm
E:\hello>cd myExpressApp
E:\hello\myExpressApp>npm install
npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated constantinople@3.0.2: Please update to at least constantinople 3.1.1
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
npm WARN notice [SECURITY] constantinople has 1 critical vulnerability. Go here for more details: https://nodesecurity.io/advisories?search=constantinople&version=3.0.2 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] uglify-js has 2 low vulnerabilities. Go here for more details: https://nodesecurity.io/advisories?search=uglify-js&version=2.2.5 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm notice created a lockfile as package-lock.json. You should commit this file.
added 101 packages in 16.256s
开始工作
E:\hello\myExpressApp>npm start
> myexpressapp@0.0.0 start E:\hello\myExpressApp
> node ./bin/www
GET / 200 514.910 ms - 170
GET /stylesheets/style.css 200 3.236 ms - 111
GET /favicon.ico 404 15.538 ms - 1032
GET / 304 13.080 ms - -
GET /stylesheets/style.css 304 1.244 ms - -
GET / 304 9.966 ms - -
GET /stylesheets/style.css 304 1.572 ms - -
CTRL+C结束服务
终止批处理操作吗(Y/N)? y
E:\hello\myExpressApp>