How do I deploy an Angular.js app?

后端 未结 3 1937
青春惊慌失措
青春惊慌失措 2021-02-05 12:38

This may be a stupid question, but I\'m wondering what platform I should use to deploy my Angular.js app? I tried using Heroku but got a \"no Cedar-supported app detected\" erro

相关标签:
3条回答
  • 2021-02-05 12:53

    I changed this line var DEFAULT_PORT = 8000; into: var DEFAULT_PORT = process.env.PORT || 8000;

    ..and then it worked. So I believe the reason is that heroku doesn't like your app running on port 8000.

    0 讨论(0)
  • 2021-02-05 13:10

    You can run an Angular app on heroku if it is served as a node.js application. Usually, when you start working with Angular seed, there is already a node webserver script in the project. I believe if there is a package.json file in the root, heroku will detect and run it as a node.js application. I'll come back and update this answer with more detail shortly.

    UPDATE

    From the Heroku docs (and I am no expert), it has this passage after the deploy section: https://devcenter.heroku.com/articles/nodejs#visit-your-application

    which basically tells you to make sure you have one dyno running. You can do that either through the web app under the settings of your app or you can run this:

    $ heroku ps:scale web=1
    

    To see if the process is running, do

    $ heroku ps
    === web: `node web.js`
    web.1: up for 10s
    
    0 讨论(0)
  • 2021-02-05 13:12

    I bet if you look at your logs you'll see something like this:

    2013-08-26T12:51:18.257006+00:00 heroku[web.1]: Starting process with command `node scripts/web-server.js`
    2013-08-26T12:51:19.109974+00:00 app[web.1]: Http Server running at http://localhost:8000/
    2013-08-26T12:51:34.369092+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path=/ host=cmwidget.herokuapp.com fwd="77.101.66.230" dyno= connect= service= status=503 bytes=
    2013-08-26T12:52:19.445974+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
    

    It means that your Angular seed app is using it's own port (8000), and Heroku doesn't allow this. You need to relinquish the assignment of the port number to Heroku.

    Easily fixed. Modify scripts/web-server.js, and change this:

    this.server.listen(port);
    

    ...to this:

    this.server.listen(process.env.PORT || port);
    
    0 讨论(0)
提交回复
热议问题