bradtraversy / mern_shopping_list

Shopping List built with MERN and Redux
605 stars 437 forks source link

Issue while deploying to heroku #48

Closed vienpham2019 closed 4 years ago

vienpham2019 commented 4 years ago

-----> Installing dependencies Prebuild detected (node_modules already exists) Rebuilding any native modules express@4.17.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/express accepts@1.3.7 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/accepts mime-types@2.1.27 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/mime-types mime-db@1.44.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/mime-db negotiator@0.6.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/negotiator array-flatten@1.1.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/array-flatten body-parser@1.19.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/body-parser bytes@3.1.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/bytes content-type@1.0.4 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/content-type debug@2.6.9 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/debug ms@2.0.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/ms depd@1.1.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/depd http-errors@1.7.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/http-errors inherits@2.0.3 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/inherits setprototypeof@1.1.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/setprototypeof statuses@1.5.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/statuses toidentifier@1.0.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/toidentifier iconv-lite@0.4.24 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/iconv-lite safer-buffer@2.1.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/safer-buffer on-finished@2.3.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/on-finished ee-first@1.1.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/ee-first qs@6.7.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/qs raw-body@2.4.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/raw-body unpipe@1.0.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/unpipe type-is@1.6.18 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/type-is media-typer@0.3.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/media-typer content-disposition@0.5.3 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/content-disposition safe-buffer@5.1.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/safe-buffer cookie@0.4.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/cookie cookie-signature@1.0.6 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/cookie-signature encodeurl@1.0.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/encodeurl escape-html@1.0.3 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/escape-html etag@1.8.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/etag finalhandler@1.1.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/finalhandler parseurl@1.3.3 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/parseurl fresh@0.5.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/fresh merge-descriptors@1.0.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/merge-descriptors methods@1.1.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/methods path-to-regexp@0.1.7 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/path-to-regexp proxy-addr@2.0.6 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/proxy-addr forwarded@0.1.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/forwarded ipaddr.js@1.9.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/ipaddr.js range-parser@1.2.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/range-parser send@0.17.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/send destroy@1.0.4 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/destroy mime@1.6.0 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/mime ms@2.1.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/send/node_modules/ms serve-static@1.14.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/serve-static utils-merge@1.0.1 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/utils-merge vary@1.1.2 /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/vary Installing any new modules (package.json)

   > nodemon@2.0.4 postinstall /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/node_modules/nodemon
   > node bin/postinstall || exit 0

   Love nodemon? You can now support the project via the open collective:
    > https://opencollective.com/nodemon/donate

   added 177 packages from 89 contributors and audited 228 packages in 7.976s

   11 packages are looking for funding
     run `npm fund` for details

   found 0 vulnerabilities

-----> Build Running heroku-postbuild

   > algorithms_simulation@1.0.0 heroku-postbuild /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c
   > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client

   up to date in 0.248s
   found 0 vulnerabilities

npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/client/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_9ae6d8f874330b53c9410b0dd2bf4a7c/client/package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent npm ERR! A complete log of this run can be found in: npm ERR! /tmp/npmcache.R3Lmg/_logs/2020-06-24T05_52_15_157Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 254 npm ERR! algorithms_simulation@1.0.0 heroku-postbuild: NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client npm ERR! Exit status 254 npm ERR! npm ERR! Failed at the algorithms_simulation@1.0.0 heroku-postbuild script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /tmp/npmcache.R3Lmg/_logs/2020-06-24T05_52_15_174Z-debug.log -----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   Some possible problems:

   - node_modules checked into source control
     https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits

   Love,
   Heroku

! Push rejected, failed to compile Node.js app. ! Push failed

heytulsiprasad commented 4 years ago

This happened to me a while ago, while I was going through Brad's series. Although it's quite a while and I mayn't remember the exact fix for this, but can say you a checklist of things you need to make sure before pushing to heroku.

Firstly, this is a very helpful post which guides you along your deployment entirely. (if nothing works)

Now you can make sure you did all these before going for deployment:

Also, while going through Heroku docs I found you can run any custom npm command as your root (to start server) command, like npm start etc, by creating a Procfile on your root directory.

The name of the file is: Procfile itself, no extension

And it shall contain something like, web: npm start or web: node index.js. With this you can run any npm command you can want to on starting your server.

If Procfile isn't present, it'll default to something like npm start (I'm not sure). You can check for yourself.

Also lastly, if your deployment is passed or somehow when you visit your live website and see Application Error, you can go through heroku logs --tail for better clarification. This saved my life!

Hopefully, this will help you.