前言
更換了新主題,在hexo g和hexo s的時候總會報如下錯誤,在主題github issues逛了一圈後,感覺應該是我的hexo版本太老了。
➜ hexo s
(node:64285) [DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.
INFO Start processing
ERROR Process failed: layout/archive.ejs
SyntaxError: Invalid or unexpected token in "/Users/lanvnal/Files/blog/themes/hexo-theme-matery/layout/archive.ejs"
at new Function (<anonymous>)
at Object.exports.compile (/Users/lanvnal/Files/blog/node_modules/ejs/lib/ejs.js:242:14)
at Function.ejsRenderer.compile (/Users/lanvnal/Files/blog/node_modules/hexo-renderer-ejs/lib/renderer.js:11:14)
at Theme._View.View.View._precompile (/Users/lanvnal/Files/blog/node_modules/hexo/lib/theme/view.js:117:31)
決定升級hexo版本,但是沒找到很明確的升級hexo的文章,遂做一下記錄。
升級
1、全局升級hexo-cli,先hexo version
查看當前版本,然後npm i hexo-cli -g
,再次hexo version
查看是否升級成功。
2、使用npm install -g npm-check
和npm-check
,檢查系統中的插件是否有升級的,可以看到自己前面都安裝了那些插件
3、使用npm install -g npm-upgrade
和npm-upgrade
,升級系統中的插件
4、使用npm update -g
和npm update --save
PS:第四步遇到了錯誤,錯誤提示如下:
> [email protected] install /Users/lanvnal/Files/blog/node_modules/hexo/node_modules/fsevents
> node-gyp rebuild
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
gyp: No Xcode or CLT version detected!
其實已經安裝過了xcode cli,但是這裏還是報錯了,估計和蘋果新系統有關,重裝就好了,操作如下:
如果像以前一樣執行xcode-select --install
會有如下報錯:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
解決辦法:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
然後再執行第四步,完美升級。