I'm trying to require some JS file in Node,
Localy - works great, but in Heroku I get this error-
Error: Cannot find module './routes.js'
my code looks like :
'use strict';
var express = require('express');
var app = express();
app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/public'));
// Application Header
app.use(function(request, response, next) {
response.header('Access-Control-Allow-Origin', '*');
response.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
response.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With, X-PINGOTHER');
next();
});
// views is directory for all template files
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
console.log('./routes.js');
require('./routes.js')(app);
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
What am I doing wrong?
Thanx!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…