A novice asked “typeeeror: express is not a function.”

  node.js, question

I am a novice. I saw a node.js tutorial on the Internet, initiated a project, and typed it down with the tutorial. The code always prompts an error when starting:

D:\nodejs\cms\app.js:3
 var app = express();
 ^
 
 TypeError: express is not a function
 at Object.<anonymous> (D:\nodejs\cms\app.js:3:11)
 at Module._compile (module.js:410:26)
 at Object.Module._extensions..js (module.js:417:10)
 at Module.load (module.js:344:32)
 at Function.Module._load (module.js:301:12)
 at Module.require (module.js:354:17)
 at require (internal/module.js:12:17)
 at Object.<anonymous> (D:\nodejs\cms\bin\www:3:11)
 at Module._compile (module.js:410:26)
 at Object.Module._extensions..js (module.js:417:10)

App.js code is as follows:

var express = require('./config/express');
 var app = express();
 module.exports = app;

Js code is as follows:

var express = require('express');
 var bodyParser = require('body-parser');
 module.express = function(){
 console.log('init express...');
 var app = express();
 app.use(bodyParser.json());
 app.use(function(req, res, next){
 res.status(404);
 try {
 return res.json('Not found');
 } catch(e) {
 console.error('404 set header after sent');
 bracket
 });
 return app;
 };

Bin/www code is as follows:

#!  /usr/bin/env node
 var app = require('../app');
 var config = require('../config/config');
 app.listen(config.port, function(){
 Log ('appstarted, listeningport:' plus config.port);
 });

package.json :

{
  "name": "cms",
  "version": "1.0.0",
  "description": "demo app",
  "main": "bin/www",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "abc",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.15.0",
    "express": "^4.13.4"
  }
}

Please help me look at it, thank you.

Js

module.express

Change to

module.exports