Here is the app.js file:
var cluster = require('cluster');
if(cluster.isMaster){
var cpuCount = require('os').cpus().length;
for(var i = 0; i < cpuCount; i++){
cluster.fork();
}
cluster.on('exit',function(){
console.log('A cluster died\n A cluster was created!');
cluster.fork();
});
}else{
var bcrypt = require('bcrypt'),
bodyParser = require('body-parser'),
express = require('express'),
session = require('express-session'),
isemail = require('isemail'),
nodemailer = require('nodemailer'),
path = require('path'),
r = require('rethinkdbdash')({
port:28015,
host:'localhost',
db: 'FPC'
}),
socket = require('socket.io');
var app = express();
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
var login = require(path.join(__dirname+'/config/login.js'));
}
Here is the config/login.js file
app.get('/login',function(req, res){
res.sendFile(path.join(__dirname+'/www/CreateAccount/index.html"));
});
When I try to launch the app it gives me an error
ReferenceError: app is not defined
at Object.<anonymous> (C:\Users\yeet\Documents\Projects\website\config\login.js:1:63)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\yeet\Documents\Projects\website\app.js:29:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:423:7)
I can't figure out why it won't just take var app = express from the app.js. And requiring all the needed modules to run this removes the purpose of making login.js it's own file
via JavascriptCoding Guru
No comments:
Post a Comment