9

When I push my node app to heroku master I get this log

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

I can't find the reason why this would happen as I clearly have in my root directory. I checked using git ls-files and it appears.

Is it possible that my application root is not the same as my repository root? How would one config that?

Joaquim Ferrer
  • 603
  • 6
  • 23

3 Answers3

12

It seems that when I push to heroku master, heroku pushes the main branch of my local repository to heroku instead of the branch I'm currently in. So what I had to do was pushing with:

git push heroku mybranchname:master

so that my branch (not the master) gets pushed

Joaquim Ferrer
  • 603
  • 6
  • 23
  • All of my codes are not in root. Actually, they are in a directory. How can I tell Heroku search for package.json in this folder instead of searching in the root of the repo? – E A May 28 '18 at 16:09
  • I think this might help you https://stackoverflow.com/questions/27519313/how-to-have-package-json-not-at-top-level-of-heroku-app#33353078 – Mahad Ahmed Sep 12 '18 at 16:41
2

One common issue is not having added the files to git.

You might be having package.json in your root directory on you device, without adding it to git, heroku can't find it.

Please check status to confirm and add if not added already

git status git add .

then followed by the usual git push heroku master assuming you are on the master branch. Hope this helps.

Rahul R
  • 111
  • 6
0

I think just pushing a branch and not the master should fix it. If you do not have a branch, I suggest you create one and push with that.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Jerryjayce
  • 1
  • 1
  • 3