解决新版 hexo 无法部署到 heroku 的错误

把 hexo 更新到最新版(3.9.0)之后,在运行 hexo deploy --generate 发现无法部署,控制台提示如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
!     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:
!
! index.php
! Procfile
! public/
!
! 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

然后看了一下 .deploy_heroku 文件夹里的 Procfile 文件,这是已经从原来的 nodeje 项目变成了 nginx 的了??这跟之前运行时环境不一样,造成了部署无法成功。

看了控制台出现的那两链接,以及 stackoverflow 的回答,需要把原来的 buildpack 给删掉,之后再部署就行了。那么就好办了

1
2
heroku buildpacks:remove heroku/nodejs -a APP
hexo deploy --generate

结束。