Stopping Heroku from running npm start + what to run instead?

后端 未结 2 540
忘了有多久
忘了有多久 2020-12-17 06:00

Disclaimer: I\'m a node.js/grunt/bower newbie.

I have a node.js/grunt/bower application that I\'m trying to deploy on Heroku. Heroku builds the application as expect

2条回答
  •  青春惊慌失措
    2020-12-17 06:15

    Thanks for the answer. After trying the tutorial mentioned above and looking at the solutions in node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON] I ended up writing a server.js file which solved the problem. And it looks like this:

    var express = require('express');
    var app = express();
    
    app.get('/', function (req, res) {
        res.sendFile(__dirname + '/index.html');
    });
    
    app.get(/^(.+)$/, function (req, res) {
        res.sendFile(__dirname + req.params[0]);
    });
    
    var PORT = process.env.PORT || 3000;
    
    app.listen(PORT);
    

提交回复
热议问题