我正在尝试将我的api上传到网络上,听说'Heroku'是一个很好的免费云平台。我做有package.json:
构建日志:
-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz
! ERROR: Application not supported by 'heroku/nodejs' buildpack
!
! The 'heroku/nodejs' buildpack is set on this application, but was
! unable to detect a Node.js codebase.
!
! A Node.js app on Heroku requires a 'package.json' at the root of
! the directory structure.
!
! If you are trying to deploy a Node.js application, ensure that this
! file is present at the top level directory. This directory has the
! following files:
!
! Bezeq.js
! Cellcom.js
! Hot.js
! MainAPI.js
! node_modules/
! package-lock.json
! Partner.js
!
! If you are trying to deploy an application written in another
! language, you need to change the list of buildpacks set on your
! Heroku app using the 'heroku buildpacks' command.
!
! For more information, refer to the following documentation:
! https://devcenter.heroku.com/articles/buildpacks
! https://devcenter.heroku.com/articles/nodejs-support#activation
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
! Push failed
为什么不起作用?
谢谢
答案 0 :(得分:0)
您是否在项目的根目录下运行了“ npm init”来创建package.json?
答案 1 :(得分:0)
我已修复它,问题出乎意料了-在package.json文件中。 我运行了'npm init',但是这次更加小心,并注意到了一些小细节。 在那之后,我再次尝试进行部署并且成功了。 谢谢阿里的指导
答案 2 :(得分:0)
遇到了同样的问题,但我的解决方案与另一个问题有关,我认为其他人可能会从中受益。 推送必须在您的主分支或分支上:main
git push heroku <your_branch>:main