---
title: "Hexo を V5 にアップグレードしたときのトラブル解決"
description: "ちょうど PC をクリーンインストールしたところで、このブログが D ドライブで新しい環境への引っ越しを待っていたので、ついでに楽しくアップグレードしてしまいました。"
author: "kidneyweakx"
published: 2021-03-18T00:00:00.000Z
updated: 2026-06-02T17:26:19.841Z
lang: ja
tags: ["程式筆記", "Javascript", "hexo"]
canonical: https://kidneyweakx.com/blog/21log-0318-hexov5?lang=ja
alternate_zh_tw: https://kidneyweakx.com/blog/21log-0318-hexov5.md
alternate_en: https://kidneyweakx.com/blog/21log-0318-hexov5.md?lang=en
---

# Hexo を V5 にアップグレードしたときのトラブル解決

ちょうど PC をクリーンインストールしたところで、このブログが D ドライブで新しい環境への引っ越しを待っていたので、ついでに楽しくアップグレードしてしまいました。

```bash
hexo: 5.4.0
hexo-cli: 4.2.0
os: Windows 10 20H2
node: 14.16.0
```

### hexo を v5.0 に更新

hexo を V5 に更新する手順はかなり簡単で、

```bash
npm install -g npm-upgrade
npm-upgrade
npm i
```

これで自動的に更新されます。ただ、メジャーアップデートにはたいてい小さな問題がつきもので、案の定いくつか warning が出ました。

#### 更新後の Error

```bash
Deprecated config detected: "external_link" with a Boolean value is deprecated. See https://hexo.io/docs/configuration for more details.
```

#### 解決方法

\_config.yml の該当部分を新しい書き方に修正します。もともと external\_link には true の選択肢しかありませんでしたが、更新後は新しいタブで開くかどうかを決められるようになっています。

```yaml
# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
# 修改這個部分
external_link:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace: ''
  wrap: true
  hljs: false
prismjs:
  enable: false
  preprocess: true
  line_number: true
  tab_replace: ''
```

***

### hexo-git-backup の push でエラー

今回の更新で、使っている hexo-git-backup の module にも大きな問題が出ました。

```bash
error: src refspec master does not match any
error: failed to push some refs to 'github'
```

この問題は issue[#40](https://github.com/coneycode/hexo-git-backup/issues/40) で回答してくれている人がいます。

解決方法はだいたい次のとおりです。`node_module/hexo-git-backup` の中で上の行を探して、`master` を backup に変えます。自分の branch は backup なので、master が見つからなかったわけです。

```jsx
// 找到這行
// commands.push(['push', '-u', t, 'master:' + repo[t].branch, '--force']);
// 更換成這行
commands.push(['push', '-u', t, 'backup:' + repo[t].branch, '--force']);
```
