1.0 操作命令
Node.js express 框架
https://www.expressjs.com.cn/
npm install -g express-generator
expressexpress --pug --git // --pug 添加对 pug 模板引擎的支持
// --git 添加 .gitignore 代码仓库排除
//无法直接安装新版pug模板
npm i
npm uninstall pug
npm i pug
npm i nodemonnpm run dev
// 开发测试
npm run start
// 使用
npm i pm2
npm run prd
// 后台进程运行
问题 1:
解决:npm install -g npm@10.4.0
问题 2:
express : 无法加载文件
1.以管理员身份打开 PowerShell。
2.运行以下命令:Set-ExecutionPolicy RemoteSigned
解决:
1.1package.json 配置文件
{"name": "express","version": "1.0.0","private": true,"scripts": {"start": "node ./bin/www","dev": "nodemon bin/www","prd": "pm2 start bin/www"},"dependencies": {"cookie-parser": "~1.4.4","debug": "~2.6.9","express": "~4.16.1","http-errors": "~1.6.3","morgan": "~1.9.1","nodemon": "^3.0.3","pug": "^3.0.2"}
}
1.2 静态地址public
views
--home
--soft
--tools
--