简体   繁体   中英

Deploy nodejs app to heroku

I used https://github.com/tommy351/hexo to create a blog and hope to deploy to heroku

hexo instruction

 Installation

$ npm install hexo -g

Quick Start

Setup your blog

$ hexo init blog
$ cd blog
$ npm install

Start the server

$ hexo server

Create a new post

$ hexo new "Hello Hexo"

Generate static files

$ hexo generate

I created at local and upload the app to heroku and it reported:

Releasing to testApp... ....done, v3

It looks like everything is OK, just confuse how to execute command line such as

hexo ***

on heroku

I executed

heroku run "hexo server"

it always said

bash: hexo: command not found

It's not the way you should deploy hexo on Heroku.

1. TL;DR - SHORT ANSWER

Hexo doc(1) says you should change your file ./_config.yml to contains something like that in this part:

deploy:
  type: heroku
  repo: git@heroku.com:jefficue.git
  message: Deployment of Hexo to heroku.

Bug for the current version (2): You should delete public/ from the file ./gitignore. You can check using this bash command. It should return nothing:

$ cat .gitignore|grep public
$

After you should run the following command at your project's root:

hexo generate
hexo deploy

2. LONGER ANSWER

If you want to execute something on Heroku the command is

heroku run something

In your case it seems hexo is not installed on Heroku. Don't do it but you could add the package hexo to your dependencies:

{  
   "name":"hexo-site",
   "version":"2.8.3",
   "private":true,
   "dependencies":{  
      "hexo-renderer-ejs":"*",
      "hexo-renderer-stylus":"*",
      "hexo-renderer-marked":"*",
      
      "connect":"2.x"
   }
}

I've added the bold line to my./package.json and it will be automatically installed during the deployment. By default the package hexo is not present. This is a bad practice to add it. You should actually:

  1. use the hexo command locally,
  2. commit / push the result to the server.

(1) http://hexo.io/docs/deployment.html
(2) https://github.com/hexojs/hexo/issues/764

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM