music-liang

Node.js 的 Express 框架学习

https://developer.mozilla.org/zh-CN/docs/Learn/Server-side/Express_Nodejs/skeleton_website

 


1.创建一个文件夹

2.在cmd命令下,进入当前文件夹

3.初始化npm 环境(否则直接下载模块会报错)
npm init -y

4.安装express模块, generator生成器
npm install express
npm install -g express-generator

5.进入应用目录,运行以下命令,即可创建一个名为 "helloworld" 的 Express 应用:
express helloworld

 

 =======================================================================

创建了express应用之后,系统有提示:
:\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
最下面2行的命令很重要!!!!!
=======================================================================

6.用下列命令可为 helloworld 应用安装所有依赖:
cd helloworld
npm install

==================================
安装了express的应用之后,需要执行 npm install。。。
在 express 应用的同级目录下指向该命令。
==================================


7.然后运行这个应用(Windows 环境):
> SET DEBUG=helloworld:* & npm start

(Linux/macOS 环境):
$ DEBUG=helloworld:* npm start


8.打开浏览器并访问 http://127.0.0.1:3000/ 将看到 Express 的默认欢迎页面。

 

分类:

技术点:

相关文章:

  • 2021-05-30
  • 2021-12-07
  • 2022-02-10
  • 2021-06-08
  • 2022-02-17
  • 2021-07-02
  • 2022-01-03
  • 2022-12-23
猜你喜欢
  • 2021-05-26
  • 2022-12-23
  • 2018-12-19
  • 2021-10-22
  • 2021-12-24
相关资源
相似解决方案