Having a HARD time deploying my MERN stack app to Heroku

Viewed 154

I've been following brad traversy's guide for hosting a full stack mern app ,

But after I run git push heroku master I keep getting this error :

$ git push heroku master
Enumerating objects: 39, done.
Counting objects: 100% (39/39), done.
Delta compression using up to 8 threads
Compressing objects: 100% (36/36), done.
Writing objects: 100% (39/39), 427.21 KiB | 8.06 MiB/s, done.
Total 39 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 12.x...
remote:        Downloading and installing node 12.20.1...
remote:        Using default npm version: 6.14.10
remote:
remote: -----> Installing dependencies
remote:        Installing node modules
remote:
remote:        > nodemon@2.0.6 postinstall /tmp/build_a03a558d/node_modules/node
mon
remote:        > node bin/postinstall || exit 0
remote:
remote:        Love nodemon? You can now support the project via the open collec
tive:
remote:         > https://opencollective.com/nodemon/donate
remote:
remote:        added 296 packages in 4.302s
remote:
remote: -----> Build
remote:        Detected both "build" and "heroku-postbuild" scripts
remote:        Running heroku-postbuild
remote:
remote:        > server@1.0.0 heroku-postbuild /tmp/build_a03a558d
remote:        > NPM_CONFIG_PRODUCTION=false npm install --prefix frontend && np
m run build --prefix frontend
remote:
remote:        up to date in 0.241s
remote:        found 0 vulnerabilities
remote:
remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_a03a558d/frontend/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_a03a
558d/frontend/package.json'
remote: npm ERR! enoent This is related to npm not being able to find a file.
remote: npm ERR! enoent
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.ZT0se/_logs/2021-01-26T16_52_50_692Z-debug.lo
g
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! server@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm
 install --prefix frontend && npm run build --prefix frontend`
remote: npm ERR! Exit status 254
remote: npm ERR!
remote: npm ERR! Failed at the server@1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additi
onal logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.ZT0se/_logs/2021-01-26T16_52_50_713Z-debug.lo
g
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common is
sues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploy
s
remote:
remote:        Some possible problems:
remote:
remote:        - Node version not specified in package.json
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying
-a-node-js-version
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to fathomless-thicket-55387.
remote:
To https://git.heroku.com/fathomless-thicket-55387.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fathomless-thicket-55
387.git'

I have no clue why I get those error messages... remote: npm ERR! path /tmp/build_a03a558d/frontend/package.json remote: npm ERR! errno -2 remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_a03a 558d/frontend/package.json'

1 Answers

You need to check

  1. Whether you have package.json file in frontend folder. You can in git and see if it is there. It may be mentioned in gitignore.

  2. Whether your heroku-postbuild runs from package.json (not the same package.json file you have in frontend folder) which is on the same level with folder frontend. Like this:

    • package.json
    • /frontend
Related