Heroku can't find package.json during build although I have it
Asked Answered
H

3

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?

Hydracid answered 16/12, 2017 at 19:58 Comment(4)
Is your package.json named exactly that, including case?Baeza
Yes, Exactly as is.Hydracid
Is there anything I can do to search for the problem?Hydracid
Are you willing to share your code repository URL?Baeza
H
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

Hydracid answered 9/1, 2018 at 19:50 Comment(2)
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?Turmeric
I think this might help you #27519813Intramuscular
P
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.

Pastorate answered 3/10, 2018 at 10:20 Comment(0)
P
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.

Prism answered 16/12, 2019 at 16:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.