Steps to Deploy Express React Redux template to Heroku - node.js

Limited experience with Node and deploying to Heroku. I've built something up using this boilerplate: https://github.com/DimitriMikadze/express-react-redux-starter but am not really certain how to set up the template for deployment to Heroku.
Any basic steps would be super helpful. Thank you!

Heroku's docs are actually really great! https://devcenter.heroku.com/articles/getting-started-with-nodejs . That will walk you through deploying their example repo, but the starter kit you linked to above will work almost exactly the same. I would walk through that tutorial to deploy Heroku's example repo first just to make sure you have their toolkit properly installed and generally understand how it works, it won't take long at all. Then I would move on to deploying the app you've built. The one change I know you'll have to make is what you put in your Procfile. Yours will need to look something like this:
web: npm run build && npm start
hope that helps!

The Heroku + NodeJS getting started tutorial was incredibly helpful. After fiddling around with deploying to Heroku I realized my problems were as following:
pm2 dependency -- as suggested I removed it and replace the npm start script to just PORT=8080 node start ./server.js
However, that caused separate problems:
A. 'start' was undefined, B. I got a Heroku error "web-process-failed-to-bind-to-port", and C. missing Webpack + other dependencies
By simply removing the hardcoded port and "start" -- so the script is now just node ./server.js as well as fixing any devDependencies AND setting my Heroku config to NPM_CONFIG_PRODUCTION: false it works now! Huzzah. Thanks for the assistance on this.

Related

Webpack Node.js on Heroku Deployment Error

I built an application with React/Node.js/PostgreSQL Webpack and now attempting to deploy on heroku.
Everything works perfectly on my localhost, but it doesn't serve on Heroku. error message image on Heroku -
I've tried multiple buildpacks to make it happen, but it still gives me the same result, and I cannot figure out the problem as my logs don't seem to have any issues.
Any ideas would be greatly appreciated.
Here is the link to my repo https://github.com/strongharris/Edu-it
To Run it:
npm install ->
npm run build ->
npm start
The problem here is with your code. I tried to deploy a copy of your project to Heroku, and it's giving me an error because config.connection does not exist when you use it in a conditional.
Here's the error:
(These logs were retrieved by me deploying the Heroku app, then running heroku logs to view the log output.)
As you can see, the error is here: https://github.com/strongharris/Edu-it/blob/master/server/database/database_config.js#L9
You'll need to re-write this code so it runs properly without that variable.

Heroku cannot find ./node_modules/.bin/forever in Procfile of Yeoman MEAN app

I've been trying to get a Yeoman generated MEAN.js app deployed to Heroku for the best part of a day without much luck.
I've carefully gone through all the steps and am pretty sure I've done everything correctly according to documentation.
After several times going through and ensuring the database is configured correctly with heroku config, removing the public/dist folder from the .gitignore, running grunt build, setting NODE_ENV=production, and running a successful Heroku build the app just continuously shows the very unhelpful Heroku Application Error page.
Upon checking the heroku logs the only thing I can find is this:
bash: ./node_modules/.bin/forever: No such file or directory
Process exited with status 127
Which clearly refers to the Procfile that contains this single line and is where the app is supposed to start from.
web: ./node_modules/.bin/forever -m 5 server.js
There is a server.jsin the root of the project so I tried modifying the Procfile to a standard web: node server.js but that doesn't fix it and I am not comfortable messing with the default Yeoman configuration.
The ./node_modules/.bin/forever is of course there where it is supposed to be. But it obviously isn't showing up or cannot be located in the live Heroku build. If anyone knows what the problem is here and how to fix it I'd much appreciate the help! Cheers!
This happened to me after I upgraded my nodejs, I can't figure out why exactly it is happening, but here is my fix for it asap,
When I ran heroku run ls node_modules/.bin/
I could not find forever there. So I installed and save it to my dependencies by running npm install forever --save
On running heroku run ls node_modules/.bin/ again, it was there and my app runs fine.
I'll sure update this soon, once I figure what exactly led to it.

Meteor requires Node v0.10.41 or later Error on heroku deployment

I recently tried deploying my first MeteorJS (1.3) application on heroku and am getting a server log error - "Meteor requires Node v0.10.41 or later". Not sure what the relationship is between node and meteor. Do meteor apps actually need a node backend or is this a meteor bug?
Also, when I run "meteor node -v" I get v0.10.43 which IS a later version so I'm not sure what the problem is when deploying.
It's a problem with buildpack "jordansissel/heroku-buildpack-meteor.git"
Meteor 1.3 requires Node 0.10.41, and this buildpack compiles node at 0.10.40.
I submitted a pull request for a new buildpack, or try my fork at https://github.com/kevinseguin/heroku-buildpack-meteor.git
I've faced the same problem with deploying new version of meteor 1.3 and also spent the best part of the day, but eventually got easy solution!
You take last buildpack for meteor 1.3:
https://github.com/michaltakac/meteor-buildpack-horse and then doing everything as shown there, but instead doing git push heroku master, you do
git push -f heroku master
So the whole bunch for your commands:
>heroku create <yourapp>
>heroku buildpacks:set https://github.com/michaltakac/meteor-buildpack-horse.git
>heroku addons:create mongolab
>heroku config:set ROOT_URL=https://<yourapp>.herokuapp.com
>git push -f heroku master
Thanks to gitjason for his advice to get the right direction.
In case anyone else comes here, after trying the fixes here my app still had errors launching on Heroku, but the error messages were not verbose and only continued to give the Node version error. This series of fixes got it going.
1. in terminal, npm install - for me this re-installed npm. I also ran "meteor update" but I knew there was no significant update that would break my app.
2. check the .gitignore file - something important might be in there. In my case, "newrelic" folder was in there but not referenced as a dependency in package.json. To fix this make sure all subfolders have a dependency reference in package.json (recommended) or else remove node_modules from .gitignore (creates extra fetching, not recommended but works).
3. use Kevin's build path above - or another updated Meteor build package - I used the horse package. Make sure you add .git to the end of the URL like so:
heroku buildpacks:set https://github.com/kevinseguin/heroku-buildpack-meteor.git --app myAppName
4. set the $PATH - in terminal:
PATH=$PATH:$HOME/.meteor
5. set the ROOT_URL in Heroku - some instructions out there say to set it as "myAppName.herokuapp.com". This causes an error in Heroku. It is fixed if you prepend, "http://", like so, "http://myAppName.herokuapp.com".
Did you search on the web or in the Meteor documentation, before posting? From the documentation, it says,
Your JavaScript code can run in two environments: the client
(browser), and the server (a Node.js container on a server).
Basically, Meteor runs on top of node JS with all the boiler plate for reactivity and other features.
EDIT:
Now meteor also has a guide.

heroku running gulp build

i am trying to install a node app onto heroku. My application requires both gulp build and gulp install to be called on the server upon instillation, however i am having troubles doing this.
I have tried writing this inside of the package.json:
"scripts":"gulp build && gulp install"
which works at first, but after about an hour the server must restart and recall the script causing for the contents of the server to be rebuilt. this removes all of my content such as newly written blogs or changes.
I have also tried using the heroku toolbelt
heroku run gulp build
heroku run gulp install
However, even though it produces the correct console write lines and looks asif it has made the necessary changes, it hasn't, the server produces an error which proves that the resources haven't been built meaning that the console command didnt make any changes to the actual server files.
Am i missing something out here? Thanks in advance.
So i have figured out that the problem lies with the fact that i have tried to use a LevelDB database on heroku. Apparently, heroku uses no-writable dynos, meaning that the levelDB database is unable to save.

Running a node.js app with upstart and Procfile

I have a node.js application.
I have written a Procfile with the following contents.
subscription-engine-processor: node index.js
Not sure whether i am doing it right, but i tried running it with the ruby gem foreman.
$ foreman start
nothing happens. The process doesn't run.
Please do comment on whether i am doing it right, if there's any other way of running this is my local. What i ultimately want to do is to export this using upstart when its finally deployed in production.
I'm not exactly sure what foreman does, but I can give you the following links so that you can read more in depth tutorials on how to setup Node with Upstart:
http://howtonode.org/deploying-node-upstart-monit
http://caolanmcmahon.com/posts/deploying_node_js_with_upstart
http://dailyjs.com/2010/03/15/hosting-nodejs-apps/
http://blog.clock.co.uk/2011/04/11/deploying-node-js-apps/
Hope these help.
You might need this https://github.com/strongloop/node-foreman its a node port of foreman.

Resources