i move my source window to ubuntu :

错误:大多数中间件(如json)不再与ExpressBundle ,必须单独安装.请看https://github.com/senchalabs/connect#middleware.

this is my source thank you

var http = require('http');
var fs = require('fs');
var express = require('express');
var mysql = require('mysql');
var ejs = require('ejs');

var app = express();
app.use(express.bodyParser());
app.use(app.router);

推荐答案

There are a number of changes with express 4.x. Like the error says, all of the middleware has been removed.

更新你的软件包.json要包含"新"包,可以找到基本列表here和完整列表here

Using your code from above, you would just need the following:

// package.json
{
  "dependencies":
  {
    "express":"*",
    "body-parser":"*"
  }
}

Then update your source to reflect the new changes:

// app.js
var http = require('http'),
    fs = require('fs'),
    express = require('express'),
    bodyParser = require('body-parser'),
    mysql = require('mysql'),
    ejs = require('ejs');

var app = express();
app.use(bodyParser.urlencoded({
    extended: true
}));
app.use(bodyParser.json());

注意这个apply.使用(app.router)也已被删除.

Json相关问答推荐

当整个数组存储为字符串时,如何在Oracle中获取json数组的大小

如何抓住引号之间的第二次出现?

过go 24小时内判断员事件的EventBridge事件模式

盒子图显示不正确

使用 jq,如何将两个属性构成键的对象数组转换为对象的索引对象?

json 字符串到 Postgres 14 中的表视图

Jolt 转换数组对象并将某些字段移动到嵌套数组

取消嵌套数组并将数组名称添加为附加字段

使用 map_values Select 包含空格的字符串未按预期工作

如何修复通过在 tsconfig.json 文件中添加allowImportingTsExtensions引发的错误 TS5023?

使用 jq 将非统一的 json 输出转换为汇总表

为什么根据其他工具,来自 aws rds 的 JSON 在 Docker 中格式错误运行?

使用 SwiftUI 在 API 调用中解码嵌套 JSON 响应时遇到问题

使用 System.Text.Json 序列化记录成员

字典和对象的模型创建问题

在 bash 中将 CSV 转换为 JSON

Spring restTemplate 获取原始 json 字符串

AJAX 将 JavaScript 字符串数组发布到 JsonResult 作为 List 总是返回 Null?

如何在 JAVA 中对 JSONArray 进行排序

通过url获取json数据并在python中使用(simplejson)