Zanmate Zanmate - 1 year ago 72
Node.js Question

Error while making a connection in Node.js

I get the following message whenever I run the code

throw new Error('Most middleware (like ' + name + ') is no longer
bundled with express and must be installed separately ^ Error: Most
middleware(like BodyParser) is no longer bundled with Express and must
be installed separately.

My code is as following:

var express = require("express"),
restful = require("node-restful");
mongoose = restful.mongoose;

var app = express();


var ProductSchema = mongoose.Schema({
var Products = restful.model("products", ProductSchema);
Products.methods(["get", "put", "post", "delete"]);
Products.register(app, "/api/products");

Console.log("Server is running at port 3000")

I've installed npm body parser and npm method override separately but it still gives me the error message.

Answer Source

It seems to me that you do not require body-parser.

You should have something like var bodyParser = require('body-parser'); and then use it like app.use(bodyParser.json());if you want the json parser for example.

Since it is no longer in express, you cannot require it and use it through express