Node.js Express 框架 2024版 笔记

1.0 操作命令

Node.js express 框架

javascript 复制代码
https://www.expressjs.com.cn/
npm install -g express-generator
express

express --pug --git 

// --pug           添加对 pug 模板引擎的支持
// --git           添加 .gitignore  代码仓库排除
//无法直接安装新版pug模板
npm i
npm uninstall pug
npm i pug
npm i nodemon

npm 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 配置文件

javascript 复制代码
{
  "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
--

2.0 增删改查 CURD

2.1 Json数据 增删改查 CURD

2.2 Mysql 增删改查 CURD

2.3 MongoDB 增删改查 CURD

2.4 Redis 增删改查 CURD

相关推荐
见过夏天16 小时前
Node.js 常用命令全攻略
node.js
RainCity1 天前
Java Swing 自定义组件库分享(十二)
java·笔记·后端
前端双越老师1 天前
我从 0 开发的 AI Agent 智语项目发布了
前端·node.js·agent
kyriewen2 天前
2026 年了,还在用 Node.js?Bun 迁移实战:20 分钟搞定,附踩坑记录
前端·javascript·node.js
donecoding2 天前
3 条命令搞定闭环 Monorepo:Lerna 版本管理 + 拓扑构建 + 自定义分发
前端·前端框架·node.js
Flynt3 天前
npm v12 来了:allowScripts 默认关闭,我的项目差点跑不起来
安全·npm·node.js
森鹿3 天前
express中间件原理以及大致实现
前端·express
叫我Paul就好4 天前
尝试 Node 搭建后端-开发框架
node.js
风止何安啊6 天前
网课倍速痛点解决:一套前端代码实现自由控速播放器
前端·javascript·node.js
糖拌西瓜皮6 天前
Node.js核心模块实战:文件、路径、HTTP与流处理
javascript·node.js