react-redux-starter-kit
react-redux-starter-kit copied to clipboard
[Question] Error trying to deploy to heroku
I have followed the instructions for deploying to heroku, however, every time I attempt to deploy I receive the following error:
error An unexpected error occurred: "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz: Request failed "502 Bad Gateway"".
Any help?
I have gotten past the above error. I basically reset my package.json to what was the latest in the repo. However, when I go through the section describing deploying to heroku I see the following:
"start:prod": { "command": "node bin/server", "env": { "NODE_ENV": "production" } }
however there is no file named 'server' inside the bin folder.
I had the same problem and struggled with this for hours: I looked through old versions of the library and found that there used to be a file called server.js, which turns out to be pretty much exactly like the file which should be in bin/dev-server.js. I reproduced the file in bin/server.js as:
const config = require('../config/project.config')
const server = require('../server/main')
const debug = require('debug')('app:bin:server')
const port = config.server_port
const host = config.server_host
server.listen(port)
debug(`Server is now running at http://${host}:${port}.`)
debug(`Server accessible via localhost:${port} if you are using the project defaults.`)
All of the documentation on the package.json setup however did not work for me at all, and what I got working in the end was this:
"build": "npm run deploy:prod"
"start": "better-npm-run start:prod"
"betterScripts": {
"start:prod": {
"command": "node bin/server",
"env": {
"DEBUG": "app:*",
"NODE_ENV": "production"
}
},
"deploy": {
"command": "npm rebuild node-sass; npm run compile",
"env": {
"DEBUG": "app:*"
}
},
"deploy:dev": {
"command": "npm run deploy",
"env": {
"NODE_ENV": "development",
"DEBUG": "app:*"
}
},
"deploy:prod": {
"command": "npm run deploy",
"env": {
"NODE_ENV": "production",
"DEBUG": "app:*"
}
}
}
Heroku with the create-react-app buildpack will run npm install followed by the build script and finally start.
If this works for you, you may also find issues with routing once the app is up: I fixed this by adding
app.get('*', function (request, response){
response.sendFile(path.resolve(project.paths.dist(), 'index.html'))
})
in main.js under the line app.use(express.static(project.paths.dist()))