Deploy Angular CLI App to Heroku

Поделиться
HTML-код
  • Опубликовано: 18 сен 2024
  • In this video, I deploy an Angular 4 app built with the Angular CLI to Heroku. This is a basic deploy - the key to a successful deployment is configuring the package.json file in your project.
    ---
    - Move necessary libraries into your dependencies from dev dependencies.
    - Run 'ng build' as a postinstall script
    - Create a small express server and have it run as a start script
    Though not demonstrated in this video, you might strongly consider serving your application over Https. You'll need to redirect non-Https requests to Https in your Express server.
    The application deployed here was one that I built in a previous video. Be sure to check it out if you're interested in building a simple gallery application in Angular JS!

Комментарии • 115

  • @marioanthony4654
    @marioanthony4654 7 лет назад +6

    thanks @Wes D for this life serving tutorial

    • @WesDoyle
      @WesDoyle  7 лет назад +2

      +Mario Anthony I hope it is useful to you!

  • @mohsenmadi3590
    @mohsenmadi3590 6 лет назад +2

    Thank you Wes! After an entire day of playing in the mud, stumbling upon your video and following your instructions got my app working form the first Enter hit after pasting the URL! It makes sense how you poked the package.json file and how you created the server.js. It makes me wonder how such important steps were missing from most other instructors I saw.

  • @SchuylerAnkeleHSR
    @SchuylerAnkeleHSR 7 лет назад +1

    Please make one for forcing SSL on Heroku. You're one of the few teachers that talk through the video. The verbal piece really helps me. Thanks for making this!

    • @WesDoyle
      @WesDoyle  7 лет назад +1

      +Schuyler Ankele great idea, will do this soon, thanks for watching!

    • @carlosrubiano105
      @carlosrubiano105 6 лет назад +1

      Plus one to SSL

  • @mezeee
    @mezeee 4 года назад

    This is the best tutorial, and still works! Just for the people is watching this video... in the server.js you just change the name of the generated folder. For this, you can execute on the project folder ng build and watch the name of ther folder generated in "dist" . Then you reeplace by this way ->
    app.use(express.static(__dirname + '/dist/theNameOfTheFolderGeneratedInDistFolder'));
    // Send all requests to index.html
    app.get('/*', function(req, res) {
    res.sendFile(path.join(__dirname + '/dist/theNameOfTheFolderGeneratedInDistFolder/index.html'));

  • @atthewarwekeptdancing2425
    @atthewarwekeptdancing2425 5 лет назад +1

    Thank you very very much! After a whole day of useless searching the web, only your video was what helped!

    • @WesDoyle
      @WesDoyle  5 лет назад

      Glad to help, Diana!

  • @hacsor22
    @hacsor22 4 года назад +5

    Thank you so much. In Angular 8 I have to run "postinstall": "ng build --aot --prod" and in server.js:
    app.use(express.static(__dirname + '/dist/name-of-my-app'));
    res.sendFile(path.join(__dirname+'/dist/name-of-my-app/index.html'));

    • @somnathjana5128
      @somnathjana5128 4 года назад +1

      Thanks 😊😘

    • @ruslan2667
      @ruslan2667 4 года назад +1

      You da best!

    • @JittoThomasjtp_21_
      @JittoThomasjtp_21_ 4 года назад +1

      "name-of-my-app"
      Is this the name specified in heroku or in our project inside package.json ??

    • @kernandez997buhub6
      @kernandez997buhub6 4 года назад

      @@JittoThomasjtp_21_ go to your-app/dist directory and you'll see

    • @charlesikeh9935
      @charlesikeh9935 4 года назад

      How do we get this to the top of the comments feed

  • @naveenfernando1852
    @naveenfernando1852 4 года назад +1

    It works like charm.Thank you sir for sharing your knowledge with us. And a special thank for
    Antonius Block
    for give a solution for those who are currently working on latest angular 8.

  • @anndvorkina1983
    @anndvorkina1983 6 лет назад +1

    Thank you! Really helped me after 2 days of useless digging in the code!

    • @WesDoyle
      @WesDoyle  6 лет назад

      +Ann Dvorkina glad to hear it!

  • @fervorviolinist5752
    @fervorviolinist5752 7 лет назад

    Thanks for all the work you've put into your Angular 4 tutorial videos! Just discovered your channel by chance today and ended up watching all of them one right after the other! You seem to have an excellent, natural instinct on how to maintain the proper instructional flow, as evidenced by the breadth of concepts you manage to cover (and helped to solidify in my head) in each video/tutorial. Hope to see more of your content, my ngMentor~

    • @WesDoyle
      @WesDoyle  7 лет назад

      +fervorviolinist Wow, thanks - glad that you are enjoying the videos! I hope they are helpful. All the best.

  • @АлексейАлимов-я6п
    @АлексейАлимов-я6п 6 лет назад +1

    Man, seriously, the best stuff. Thank you!

  • @ronysmile4409
    @ronysmile4409 7 лет назад +2

    Awesome tutorials sir, Please make tutorials on Form Validation and performing post request to it

    • @WesDoyle
      @WesDoyle  7 лет назад +2

      +Rony smile good idea, I'll consider working with forms in an upcoming video. Thanks for the suggestion!

  • @rohitpratapsingh3068
    @rohitpratapsingh3068 6 лет назад +1

    Thanks a ton! Very informative and crisp. Keep going!!

    • @WesDoyle
      @WesDoyle  6 лет назад +1

      +Rohit Pratap Singh thanks for watching! All the best

  • @jwpjsbdj
    @jwpjsbdj 5 лет назад +3

    I could not open the app on heroku unless I changed "scripts" { "start" : "ng serve" } to "scripts" { "start" : "node server.js" }.

  • @chandramohanjagtap1300
    @chandramohanjagtap1300 7 лет назад +1

    Excellent all your Angulars video and App keep it up and plz Make more Apps

    • @WesDoyle
      @WesDoyle  7 лет назад +2

      +Chandramohan Jagtap thanks, will do!

  • @jeromeavelino4113
    @jeromeavelino4113 7 лет назад +1

    great help! keep doing them vids man and ill keep liking them! much respect from Philippines.

    • @WesDoyle
      @WesDoyle  7 лет назад

      Glad to hear, Jerome! Best of luck!

  • @hacsor22
    @hacsor22 4 года назад +2

    If your bundle size is too big, replace "postinstall": "ng build --aot --prod" with "heroku-postbuild": "ng build --prod"

  • @tradeonetradeone6258
    @tradeonetradeone6258 6 лет назад +1

    What is the purpose of /dist/index.html? If my app uses routing, do I need to put these routs into index.html?

  • @DEBRISTHEREOF
    @DEBRISTHEREOF 6 лет назад +1

    Brilliant! Just what I was looking for :)

    • @WesDoyle
      @WesDoyle  6 лет назад +1

      +Paul Wr glad to hear it, thanks for watching

  • @yanivsalman9685
    @yanivsalman9685 6 лет назад +1

    hey wes doyle.. i will suggest run the command: npm install npm@latest -g
    version 3 is really slow compare to 5+ and people dont know that when you install node.js it dosent install the latest version of npm which is much faster today! yarn and npm are now similar. i i guess yarn is still faster but not like it used to be compare to npm 5.4

  • @exaltedA
    @exaltedA 4 года назад +2

    Very Useful, Thank you!!

    • @WesDoyle
      @WesDoyle  4 года назад

      Glad it was helpful!

  • @maiquerosa8963
    @maiquerosa8963 7 лет назад +1

    pretty cool man... thanks.. its more easy than i expected

    • @WesDoyle
      @WesDoyle  7 лет назад +1

      +Maique Rosa glad to hear it, thanks for the message

  • @silberJon
    @silberJon 6 лет назад +1

    Awesome knoledge here. But advantages does this deploy method has over uploading just the dist folder? thanks

  • @chr1so
    @chr1so 4 года назад +1

    Thank you very much for the tutorial, it has been very useful for so many applications I have created, plus you are super handsome.

  • @akashpotdar6841
    @akashpotdar6841 6 лет назад +2

    Thanks for the video,
    I did everything and I see my app undeployed, logs say H10.
    How do I go about fixing the errors, basically is there any way we track errors, besides from command heroku logs?
    My ERR: npm ERR! Failed at the mean@0.0.0 start script 'node server'.

  • @adesheddie1
    @adesheddie1 5 лет назад +2

    Thanks, Can you suggest me a proper video like yours for uploading angular+express app to digital ocean ?

  • @PedroJSaba
    @PedroJSaba 6 лет назад +1

    It works, thank you very much for the contribution!

    • @WesDoyle
      @WesDoyle  6 лет назад

      Thanks Pedro!! Glad to hear it

  • @chr1so
    @chr1so 5 лет назад +1

    I am able to deploy to heroku but when I try to open the application I get this error: Error: ENOENT: no such file or directory, stat '/app/dist/index.html'.
    Any ideas?

  • @wajihanaqvi3972
    @wajihanaqvi3972 6 лет назад +1

    thanks! i have my server side in node.js all data coming from the mongodb in frontend which is developed in angular 2 can i deploye both project on heruku in one project guide me please
    what is the best approach to deploye my both projects and run

  • @dinesh512512
    @dinesh512512 6 лет назад +1

    Thanks Sir, Awesome tutorial

    • @WesDoyle
      @WesDoyle  6 лет назад +1

      Thanks, hope it's helpful

  • @RosieJaneEnomar21
    @RosieJaneEnomar21 2 года назад

    hello how to deploy when your repo has multiple folders, and one of the folder is the angular project? wanted to deploy from dev branch, i tried set up everything in angular folder.

  • @shree3242
    @shree3242 5 лет назад +1

    How to serve images from aws? I have images in the assets folder, what is the efficient way to load them in the webpage?

  • @btbam06
    @btbam06 6 лет назад +1

    Great video, thanks!

  • @saalamalaas
    @saalamalaas 3 года назад

    amazing work !

  • @johnnysitu
    @johnnysitu 7 лет назад +1

    Thanks Wes for this awesome tutorial, one quick question if you don't mind, if I want to run Angular 2/4 + node locally without the Angular production build, which file should be the access point since the "dist" folder doesn't exist anymore?

    • @WesDoyle
      @WesDoyle  7 лет назад +1

      Hi Johnny Situ! when I run Angular CLI projects locally, I typically just use the built-in server and serve up the app using ng serve, which I believe serves the files in memory. You could write a small express server, build the app locally (which would produce the dist folder), and serve it that way, also. There is this link (github.com/angular/angular-cli/wiki/stories-disk-serve) which has some information about running ng build --watch, which apparently will compile the app and provide the build on disk, followed by running something like lite-server to serve the app.

    • @WesDoyle
      @WesDoyle  7 лет назад +1

      Hope this is helpful!

  • @JamesTovarArt
    @JamesTovarArt 6 лет назад +1

    Hola amigo, Tengo una aplicacion angular 5 y lo tengo local con un "start": "ng server --proxy-config proxy.conf.json", Quiero subir la aplicacion a heroku pero con el proxy ya que el backend esta alojado en otro lado

  • @acidineydias
    @acidineydias 6 лет назад +1

    Wes, Thank you so much man, really you help me so much

    • @WesDoyle
      @WesDoyle  6 лет назад +2

      +Acidiney Dias Glad to help

  • @McKisiek
    @McKisiek 6 лет назад +1

    Hey Wes, everything works fine for me, but I came across one problem. When I use routing and try to refresh website, I receive "CANNOT GET /list" statement. How to avoid this? Thanks for the video, it's amazing!

  • @TheWizarion
    @TheWizarion 6 лет назад +1

    Thanks for this tutorial, you saved my life. =´)

  • @erandagan1chanel
    @erandagan1chanel 6 лет назад

    Thanks @Wes Doyle vidoe is awsome and solve my deployment issues to heroku

  • @arvindsreenivas
    @arvindsreenivas 7 лет назад +1

    this is perfect :) thank you! :)

    • @WesDoyle
      @WesDoyle  7 лет назад +2

      +Arvind Sreenivas - no problem at all, man - hope it is helpful!

  • @andriiyurchuk3299
    @andriiyurchuk3299 4 года назад +1

    Thanks! Thanks! Thaaanks!!!

  • @GautamKumar-uideveloper
    @GautamKumar-uideveloper 6 лет назад +1

    Awesome Video... :)

  • @saeedkhan321
    @saeedkhan321 6 лет назад +1

    thanks man. it works well

  • @linocatucci
    @linocatucci 6 лет назад +1

    well done!

  • @yanivsalman9685
    @yanivsalman9685 6 лет назад

    hey Wes it not working for me i did exactly like you 2 times! i have node 8.9.1 npm 5.5.1 express and i have an empty app with just one and still problems 3d try still got an error! probably something is missing maybe in angular5 i need to do something else? add another thing?

  • @Mody9513
    @Mody9513 7 лет назад +1

    life saver thanks mate

    • @WesDoyle
      @WesDoyle  7 лет назад

      Glad to hear it, all the best to you

  • @Mr.WhiteBeard
    @Mr.WhiteBeard 7 лет назад +2

    Hi, how about SEO on angular apps?

  • @kooldandy
    @kooldandy 6 лет назад

    I followed you tutorial but getting this error after the deployment on HEROKU
    Error: ENOENT: no such file or directory, stat '/app/dist/my_proj_name/index.html'

  • @Polacosendrea
    @Polacosendrea 4 года назад +1

    Hello! great tutorial, can you do one doing a continues deployment with gitlab and yml files? thanks!

  • @amitmoral
    @amitmoral 5 лет назад +1

    Hello I upload my file successfully but i get error Application error
    An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command

    • @AreebAhmedKhan
      @AreebAhmedKhan 4 года назад

      Hi amit, I have got the same error. Did you find any solution regarding this error?

  • @octaviodanieli3036
    @octaviodanieli3036 7 лет назад +1

    thank you so much :)!

  • @aravindravva3833
    @aravindravva3833 4 года назад +1

    no such file /app/dist/frontend/index.html can someone help please

  • @MariamaBK
    @MariamaBK 4 года назад

    Hi Wes, thanks this was a very helpful video. But I also have a backend project that's servers my graphql server and communicates with my neo4j database.
    How do I deploy the webapp(Angular project) and backend(graphql) together?

  • @emmanueladeola8232
    @emmanueladeola8232 4 года назад

    Tried this with my angular js 8 application but its not working, please is there any other way

  • @bpatel545
    @bpatel545 4 года назад +1

    Thank you

  • @KleinKwakuFHouzin
    @KleinKwakuFHouzin 5 лет назад

    Thanks Akpe

  • @mostafanourialamouti7373
    @mostafanourialamouti7373 5 лет назад +1

    I love you man :)

  • @legen_dary42
    @legen_dary42 6 лет назад

    All I get is a blank screen. index.html is loaded, but nothing is there. ng serve works fine, but app will not work using express. I've double checked all of my spelling and all of my paths. At first the build was failing at the postinstall script but I removed the target option since it wasn't mentioned anywhere in the docs regarding build and it deployed. If you feel like taking a look, it's at github.com/Bus42/mtg-counter.git Maybe something in Angular has changed since you wrote this tutorial.

  • @josefeds
    @josefeds 7 лет назад +1

    Great!

  • @manogaransa2814
    @manogaransa2814 Год назад

    I am getting a below error "Unable to get local issuer certificate". Please help on this
    heroku login
    Warning: Ignoring extra certs from `C:\path\to`, load failed: error:02001005:system library:fopen:Input/output
    error
    » Warning: heroku update available from 7.53.0 to 7.63.4.
    heroku: Press any key to open up the browser to login or q to exit:
    Error: unable to get local issuer certificate

  • @RahulDas-rg4ky
    @RahulDas-rg4ky 6 лет назад

    I am getting this error please help
    [remote rejected] master -> master (pre-receive hook declined)
    Please tell me the solution to this error

  • @damiansoriaweb
    @damiansoriaweb 6 лет назад

    hi doyle, have problem with my server worked in heroku?

  • @Jyo_tsna_Singh
    @Jyo_tsna_Singh 7 лет назад

    Hey Wes,
    Thanks for the great tutorial.
    I'm stuck at 'git push heroku master'
    Error:
    Failed at the pixabay-api-image-search@0.0.0 postinstall script.

  • @nelsonking
    @nelsonking 6 лет назад +1

    How did you get vim to work on your PC? I wanna know your setup please!

    • @WesDoyle
      @WesDoyle  6 лет назад

      I'm using gvim here - I'd like to do a video about getting set up on Windows sometime. My vimrc is available in my dotfiles on Github: github.com/wesdoyle/dotfiles. I use a patched font to make powerline / airline look nice!

  • @noraguilar9418
    @noraguilar9418 6 лет назад

    Login is currently incompatible with git bash/Cygwin/MinGW
    This is the error that appear when i insert the Email after $ Heroku Login... someone knows how fix that? i

    • @noraguilar9418
      @noraguilar9418 6 лет назад +1

      Actually, the problem is because i need to Login in the Command prompt first... and after that is working in git Bash

  • @nagenderpratapchauhan7154
    @nagenderpratapchauhan7154 7 лет назад

    some error occur in my project ....can u suggest me

  • @darshanmarathe
    @darshanmarathe 4 года назад

    Please add a video for heroku SSL

  • @oraycionsis21
    @oraycionsis21 6 лет назад

    is this applicable in angular 6?

  • @ankitapatil1433
    @ankitapatil1433 7 лет назад +1

    Hi Wes,
    Thank you so much for sharing your knowledge. I like watching your videos and I must say you are one of the best teachers with the structured and detail-oriented approach.
    I have summarized your this lecture. You can check here:
    github.com/patilankita79/Notes_DeployingAngularCLIAppToHeroku

    • @WesDoyle
      @WesDoyle  7 лет назад

      +Ankita Patil thank you for the message, I hope it's useful and am glad that we can learn together. All the best!

  • @rohitr1439
    @rohitr1439 7 лет назад

    Hi Cannot able to deploy can you please help me?

  • @RodrigoSouza-jt8uq
    @RodrigoSouza-jt8uq 6 лет назад +1

    oi eu sou o theo filho do rodrigo tudo bem

  • @danielmethner6847
    @danielmethner6847 4 года назад +1

    Jeez what's with the background music?

  • @nishavprasad5906
    @nishavprasad5906 7 лет назад +1

    Hi, thank you for the simple and awesome video :) . Everything is working fine untill i reload the application, then it gives me 404 error. like for example when the link is video-player-app.herokuapp.com/videos it gives me 404, but when i remove /videos part it works fine again. Any idea what might be causing this error. And also slug size of my deployed application is quite large i.e 55.8 MB.. is it normal ??

    • @WesDoyle
      @WesDoyle  7 лет назад +1

      +Nisha V Prasad - Thanks for the comment! The 404 url issue is something I only discovered recently, but there are ways to work around this. stackoverflow.com/questions/31415052/angular-2-0-router-not-working-on-reloading-the-browser as a starting point. I may make a specific video about this in the future. Regarding the size of your app - are you deploying large amounts of static data (ie images, etc)?

    • @nishavprasad5906
      @nishavprasad5906 7 лет назад

      Thank you for the quick reply. will try to resolve this. And any suggestions on how to deal with static data in the application while deploying.?

  • @Jyo_tsna_Singh
    @Jyo_tsna_Singh 7 лет назад +1

    I created a simple cheatsheet following this tutorial. You can check it out in github
    github.com/Jyotsna-Singh/CheatSheets/blob/master/AngularJS/Deploy-Angular-CLI-Heroku.md
    Thanks!

    • @WesDoyle
      @WesDoyle  7 лет назад

      Wow, Jyotsna, really great resource! Thank you.

  • @BoB-eu
    @BoB-eu 6 лет назад

    Not working anymore :( !

  • @dixienormus8097
    @dixienormus8097 6 лет назад

    update this no longer works.

  • @aravindravva3833
    @aravindravva3833 4 года назад +1

    Its outdated