Node.js快速创建一个Express应用的几个步骤

Node.js 的 Express 框架学习

 

转载和参考地址:

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

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应用。下面的截图就是这个用法。

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

创建了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

7.然后运行这个应用(Windows 环境):

> SET DEBUG=helloworld:* & npm start

(Linux/macOS 环境):

$ DEBUG=helloworld:* npm start

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

 

posted @   He_LiangLiang  阅读(1117)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2013-04-12 STL学习笔记-- priority_queue
点击右上角即可分享
微信分享提示