我試圖要求在節點的一些JS文件, Localy - 偉大工程,但在Heroku的我得到這個錯誤 -的Heroku找不到模塊
Error: Cannot find module './routes.js'
我的代碼如下所示:
'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'));
});
我做錯了什麼? Thanx!
你確定你確實提交了這個文件嗎?因爲代碼對我來說很好。 –
Heroku上存在該文件嗎?第一:'heroku運行bash'然後:'cat routes.js'看。 – hunterloftis