$ express -e
Usage: express [options] [dir]
Options:
-h, --help output usage information
-V, --version output the version number
-e, --ejs add ejs engine support (defaults to jade)
--hbs add handlebars engine support
-H, --hogan add hogan.js engine support
-c, --css <engine> add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
--git add .gitignore
-f, --force force on non-empty directory
文件夹下会出现如下文件
package 里面是依赖的插件模块 使用 $year/npm/cnpm install 安装依赖
只有start 可以 npm start 全称是 npm run start
其他的可以 node 文件名
或者自定义一个 “d”:"node -v"
然后 $npm run d
启动
$ npm start
会提示
> node ./bin/www
找到这个目录 查看到端口号3000
locahost:3000 打开
剖析www目录 重要的三步 服务器app具体如何配置?
剖析app目录
//配置路径 __dirname当前路径
//c:...../webpack/src/js/index.js
app;path.join(__dirname,“src/js/index.js”)
www app两个文件夹 为我们 创建了一个服务器 设定了路由、
<%# %> #会把标签进行注释
<%= %> =会把标签进行转义
<%- %>-不会把标签转义
两个的作用都是用来存放数据的
.ejs里全是字符串
开启一个新的项目
mkdir 文件名
cd 文件名
初始化 cnpm init -y
搭建基本框架Express 应用生成器express -e
安装package.json文件里面的依赖yarn/cnpm/npm install
修改开启服务器的命名 supervisor .bin/www 开启一个端口号为3000的服务器并实时监听