我正在使用 cloud9 ide 并收到标题中描述的错误。文件结构如下所示
client/
views/
-index.ejs
routes/
-index.js
-server.js
server.js 文件
var path = require('path');
var async = require('async');
var express = require('express');
var router = express();
var server = http.createServer(router);
router.use(express.static(path.resolve(__dirname, 'client')));
router.set('view engine','ejs');
//app.set('views','app/views');
router.locals.siteTitle = "Meetups";
//router.use(express.static(path.resolve('./public')));
router.use(require('./client/routes/index'));
router.use(require('./client/routes/speaker'));
server.listen(process.env.PORT || 3000, process.env.IP || "0.0.0.0", function(){
var addr = server.address();
console.log("Chat server listening at", addr.address + ":" + addr.port);
});
当我在路由文件夹中的 index.js 收到错误时
TypeError:无法读取未定义 router.get 的属性“get”('/',function(req,res){
var express = require('express');
var router = express.Router();
router.get('/',function(req,res){
res.render('index',{
pageTitle:'Home',
pageID:'home',
});
});
module.exports = router;