MustansirZia / next-express-bootstrap-boilerplate

:zap: JavaScript boilerplate for a full stack app built using React.js, Next.js, Express.js, react-bootstrap, SCSS and full SSR with eslint.
MIT License
112 stars 20 forks source link

Issues on deploy to heroku #8

Closed ShintaroNippon closed 5 years ago

ShintaroNippon commented 5 years ago

Hi there I'm trying to deploy to an heroku app but it goes an error on node app.js

can you help me please?

i have tried too "start": "next start -p $PORT",

ShintaroNippon commented 5 years ago

currently im getting this...

https://test.herokuapp.com/_next/static/VprFLaLvekNmzlVsEkO_S/pages/index.js and it shows a loading of page... and doesnt show the index

ShintaroNippon commented 5 years ago

i had var port = process.env.PORT || 3000; "start": "npm run build && env NODE_ENV=production node app.js -p $PORT ",

ShintaroNippon commented 5 years ago

<script src="/_next/static/runtime/main-0659896f75e70f677900.js"

ShintaroNippon commented 5 years ago
ShintaroNippon commented 5 years ago

i ran

npm run start

next-express-bootstrap-boilerplate@0.1.1 start /Users/carlosmanuelmouravieira/Desktop/projects/frontend/learn npm run build && env NODE_ENV=production node app.js -p $PORT

next-express-bootstrap-boilerplate@0.1.1 build /Users/carlosmanuelmouravieira/Desktop/projects/frontend/learn cd app && next build

Creating an optimized production build ...

Using external babel configuration Location: "/Users/carlosmanuelmouravieira/Desktop/projects/frontend/learn/app/.babelrc" Compiled successfully.

┌ /_app ├ /_document ├ /_error ├ /box/main ├ /box/suggestions ├ /dashboard/dashboard ├ /employee/login ├ /employee/main ├ /getPageContext ├ /ideas/main ├ /ideas/suggestions ├ /index ├ /index.1 ├ /index/data ├ /main/main └ /post

MustansirZia commented 5 years ago

Hi @ShintaroNippon! For now, I can recommend one change. The start script probably doesn't need to have the npm run build part. You can remove it and then try again as Heroku will run the build by itself. The loading page could be due to the fact that your app doesn't bind to the PORT in time. (Heroku has a timeout if your app doesn't start within a few seconds of calling npm start and the build step might cause it not to) So the only two changes you need to do is remove the build step inside the start script and as you have correctly done write start(process.env.PORT || 9001); instead of start(9001);.

MustansirZia commented 5 years ago

Feel free to close the issue if you're satisfied.

ShintaroNippon commented 5 years ago

Sorry a late answer, I already could deploy to heroku, many thanks...

But now I'm facing this issue


> next-express-bootstrap-boilerplate@0.1.1 dev /home/shintaro/Desktop/projects/github/frontend
> nodemon app.js

[nodemon] 1.19.0
[nodemon] reading config ./nodemon.json
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGHUP to 20111 to restart
[nodemon] ignoring: ./node_modules/**/* ./.next/**/* ./app/**/*
[nodemon] watching: app.js
[nodemon] watching extensions: js,json
[nodemon] starting `node app.js`
[nodemon] forking
[nodemon] child pid: 20124
[nodemon] watching 1 file
Compiling ...

but when I made localhost:3000 - my port

it doesn't loads

I have updated nodemon and created thid nodemon .json

{
    "verbose": true,
    "ignore": ["node_modules", ".next","app/"],
    "watch": ["app.js"],
    "ext": "js json"
}

in package.json I have this

"dev": "nodemon -w app.js app.js"

Could you help me please...

Thanks Carlos Vieira