Reputation: 461
i will use nodemon start command but getting error. Can you help me?
ReferenceError: server is not defined
var fs = require('fs');
var express = require('express');
var path = require('path');
var other = require('./others');
var app = express();
app.get('/index', other.index);
app.get('/', other.index);
server.listen(8006);
var path = require('path');
module.exports.index = function(req, res)
{
res.sendFile(path.join(__dirname, 'index.html'));
}
Upvotes: 1
Views: 2743
Reputation: 4553
The variable
server
is not defined in your code.
It should be app.listen(8006)
Upvotes: 1
Reputation: 6559
You have a typo in line 4. Your module name is 'other'. So while importing the module you should use
var other = require('./other');
Instead, you are using
var other = require('./others'); // change others to other
Your final app.js should be looks like
var fs = require('fs');
var express = require('express');
var path = require('path');
var other = require('./other');
var app = express();
app.get('/index', other.index);
app.get('/', other.index);
app.listen(8006);
Make sure you installed the express module in your project.
Upvotes: 0