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

99封情书 提交于 2021-02-07 05:49:06

问题


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?


回答1:


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




回答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.




回答3:


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.



来源:https://stackoverflow.com/questions/47849470/heroku-cant-find-package-json-during-build-although-i-have-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!