Hexo 5.x.x リリース
According to our benchmark (which we run in every pull request to detect regression), Hexo 5 processed 500 posts in 16 seconds, whereas 4.2.0 processed 300 posts at the same time.
しばらく見ないうちに Hexo のメジャーバージョンが上がって、記事執筆時点では5.2.0がリリースされていました。いろいろ改善されているらしく、特に4系に固執する理由もないのでアップデートすることにした次第です。
まずはアップデート
公式 に従っています。hexo-cli はついでに上げました。このあたりは特に問題なかったです。
hexo-cli の更新
$ yarn global add hexo-cli
yarn global v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.1.2: The platform "win32" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
warning Your current version of Yarn is out of date. The latest version is "1.22.5", while you're on "1.22.4".
info To upgrade, download the latest installer at "https://yarnpkg.com/latest.msi".
success Installed "hexo-cli@4.2.0" with binaries:
- hexo
Done in 2.18s.
package.json の修正
- "hexo": "^4.2.0",
+ "hexo": "^5.2.0",
_config.yml 修正
非推奨の設定を修正しています。
- external_link: true
+ external_link:
+ enable: true
yarn install 実行
$ yarn install
yarn install v1.22.4
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.1.2: The platform "win32" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.11: The platform "win32" is incompatible with this module.
info "fsevents@1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
warning hexo-generator-robotstxt@0.2.0: The engine "hexo" appears to be invalid.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 4.21s.
ローカルで確認
hexo s
してローカルで確認した限りは特に問題も見られませんでした。
しかしデプロイ時にエラー発生
エラー内容
error hexo@5.2.0: The engine "node" is incompatible with this module. Expected version ">=10.13.0".
nodeのバージョンが足りない?
いまいくつなのか
Netlifyのサイトから確認できるデプロイのログによると v8.17.0 でした。たしかに足りてないです。ローカル環境ではv12.16.2を使っていたので失敗しなかったと思われます。ということは Netlify 側での node.js バージョンをどうにかしないといかんてことですね。
Now using node v8.17.0 (npm v6.13.4)
Netlify 側の Node.js バージョンをどうにかする
幸いなことに公式サイトであっさりやり方が見つかりました。
いくつかやり方が載ってましたので紹介します。例えば v12.16.2
を指定するなら以下のようになります。
1. 環境変数で対応
ここでは設定ファイルを使っていますが、Site settings > Build & deploy > Environment > Environment variables
でNetlifyのサイト上で設定するでもOKかと思います。
NODE_VERSION=v12.16.2
2. .nvmrc(or .node-version) で設定
プロジェクト直下に .nvmrc
または .node-version
を作る方法でもOKです。
v12.16.2
環境変数でも .nvmrc でもどちらでも良いですが今回は .nvmrc
を追加する方向で対応してみました。
再デプロイして無事成功
ログから一部抜粋しています。無事 v12.16.2 でデプロイが実行・終了しました。ページも確認しましたがいまのところHexo5系に上げた影響もなく問題なさそうです。
Attempting node version 'v12.16.2' from .nvmrc
Downloading and installing node v12.16.2...
Downloading https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz...
Now using node v12.16.2 (npm v6.14.4)
Site is live ✨
Finished processing build request in 1m37.644297015s
もし似たようなことがあったらご参考ください。
参考