Home>

We are currently making a system that uses Nonde.js express and implements it in MVC.

-Problem
When I tried to run server, an error that I had never seen occurred, so I asked a question.

App.js is configured to be used properly.

controller

var express = require ('express');
var router = express.Router ();
var user = require ('../ model/user');
// Additional processing
router.get ('/', function (req, res, next) {
    var data = {
        title: "Add",
    }
    res.render ('add', data);
});
// Additional processing
router.post ('/', function (req, res, next) {
    console.log ("aaa");
    var mn = req.body.mem_name;
    var ag = req.body.mem_age;
    var ji = req.body.mem_join;
    var sl = req.body.mem_skill;
    console.log (mn, ag, ji, sl);
    user.addMember (mn, ag, ji, sl,);Here, model is called.
    res.redirect ('/ admin');
});
module.exports = router;

model

var sqlite3 = require ('sqlite3');
var db = new sqlite3.Database ('ChieproDB.sqlite3');
// Add member
var addMember = (men_name, mem_age, mem_join, mem_skill) =>{
    db.run ('insert into member (mem_name, mem_age, mem_join, mem_skill) values ​​(?,?,?,?)', men_name, mem_age, mem_join, mem_skill);
}
module.exports = {addMember}

It's such a simple system, but I get an error like this

PS C: \ Users \ ********* \ Desktop \ atm>npm start
>[email protected] start C: \ Users \ ********* \ Desktop \ atm
>node ./bin/www
express-session deprecated undefined saveUninitialized option;provide saveUninitialized option app.js: 24: 9
C: \ Users \ ********* \ Desktop \ atm \ node_modules \ express \ lib \ router \ index.js: 458
      throw new TypeError ('Router.use () requires a middleware function but got a' + gettype (fn))
      ^
TypeError: Router.use () requires a middleware function but got a Object
    at Function.use (C: \ Users \ ********* \ Desktop \ atm \ node_modules \ express \ lib \ router \ index.js: 458: 13)
    at Function.<anonymous>(C: \ Users \ ********* \ Desktop \ atm \ node_modules \ express \ lib \ application.js: 220: 21)
    at Array.forEach (<anonymous>)
    at Function.use (C: \ Users \ ********* \ Desktop \ atm \ node_modules \ express \ lib \ application.js: 217: 7)
    at Object.<anonymous>(C: \ Users \ ********* \ Desktop \ atm \ app.js: 34: 5)
    at Module._compile (module.js: 652: 30)
    at Object.Module._extensions..js (module.js: 663: 10)
    at Module.load (module.js: 565: 32)
    at tryModuleLoad (module.js: 505: 12)
    at Function.Module._load (module.js: 497: 3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm.There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C: \ Users \ ********* \ AppData \ Roaming \ npm-cache \ _logs \ 2018-09-03T01_45_21_688Z-debug.log