krzysztofsopa / react-redux-node-authentication

React, Redux, NodeJS, MongoDB, express authentication starter kit
6 stars 3 forks source link

Deploy on heroku #3

Open moafzalmulla opened 6 years ago

moafzalmulla commented 6 years ago

Any idea why I get this error when I try: git push heroku master ???

git push heroku master Counting objects: 12307, done. Delta compression using up to 4 threads. Compressing objects: 100% (7660/7660), done. Writing objects: 100% (12307/12307), 11.20 MiB | 5.71 MiB/s, done. Total 12307 (delta 4073), reused 12301 (delta 4071) remote: Compressing source files... done. remote: Building source: remote: remote: -----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz remote: Node.js: package.json not found in application root remote: remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure remote: remote: ! Push failed remote: Verifying deploy...

krzysztofsopa commented 6 years ago

I assume from the output - missing package.json - you are trying to deploy to heroku main repository but you should deploy separately front and api application.

moafzalmulla commented 6 years ago

Ok so I deployed Api separately... that worked. But when I try deploy front end I get heroku error. I edited package.json like this as I noticed we never has "start" command under scripts.

{ "name": "react-front-auth", "version": "1.0.0", "description": "desc", "main": "dist/demo", "scripts": { "watch": "webpack --progress --colors --watch --config ./build.config.js", "start": "webpack --config ./build.config.js && cd dist && live-server --entry-file=index.js" }, "author": "Krzysztof Sopa <krzysztof.sopa@gmail.com>", "license": "MIT", "private": true, "dependencies": { "immutable": "^3.8.2", "lodash": "4.13.1", "material-ui": "0.15.1", "npm-run-all": "^4.1.2", "react": "15.1.0", "react-dom": "^15.1.0", "react-redux": "^4.4.5", "react-router": "^2.5.2", "react-tap-event-plugin": "^1.0.0", "redux": "^3.5.2", "redux-thunk": "^2.1.0", "superagent": "^2.0.0" }, "devDependencies": { "babel-core": "^6.26.0", "babel-loader": "^6.4.1", "babel-preset-es2015": "6.3.13", "babel-preset-react": "6.3.13", "path": "0.12.7", "webpack": "1.12.12" } }

Still no joy.....

How does that package.json for your front folder look ? for the one you deployed?

moafzalmulla commented 6 years ago

?

krzysztofsopa commented 6 years ago

Hi!

Finally I found some time to check it. It was a long, long time ago and the solutions is not the most beautiful but it works. You should build the front project. This should output to dist folder JavaScript file with source code and libraries in one file with this name: https://github.com/krzysztofsopa/react-redux-node-authentication/blob/master/front/dist/index.html#L16 If the name will be diff just change it. Then you can deploy dist folder to heroku.

For sure there is better way to do it, eg. creating start script which will build prod version of the application, start node server and serve the app through it. Unfortunately I don't have much time right now to do it. Other option would be to use docker containers and just deploy them to AWS.

If you feel like you could improve this part of application I would be really grateful :)

moafzalmulla commented 6 years ago

Hey thanks!

I want to just that, also a bootstrap version.

I run build, and push all to heroku.

So are you saying i should just push contents of dist folder?

In your package.json you have main : dist/demo.js....... but demo.js doesnt exist?

I will try below in mean time.

Cheers

Mo

On Mon, 2 Apr 2018, 23:58 Krzysztof Sopa, notifications@github.com wrote:

Hi!

Finally I found some time to check it. It was a long, long time ago and the solutions is not the most beautiful but it works. You should build the front project. This should output to dist folder JavaScript file with source code and libraries in one file with this name: https://github.com/krzysztofsopa/react-redux-node-authentication/blob/master/front/dist/index.html#L16 If the name will be diff just change it. Then you can deploy dist folder to heroku.

For sure there is better way to do it, eg. creating start script which will build prod version of the application, start node server and serve the app through it. Unfortunately I don't have much time right now to do it. Other option would be to use docker containers and just deploy them to AWS.

If you feel like you could improve this part of application I would be really grateful :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/krzysztofsopa/react-redux-node-authentication/issues/3#issuecomment-378072573, or mute the thread https://github.com/notifications/unsubscribe-auth/ACXR1sspVHxOVmPVgxLaKzBqf-zOayoNks5tkq0vgaJpZM4S3gbb .