天天看點

Hexo:[DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.

這隻是一個警告

首先我們可以從字面上了解:廢棄警告,

fs.SyncWriteStream

已經被廢棄了。注意是警告,而不是錯誤,不影響程式運作,是以其實我們可以不予理會。

如果你非要處理,參考下文。

始末

出現問題的原因

Node.js官方API:

fs.SyncWriteStream類從來就不是一個公共可通路的API,現在已經被删除了。沒有其他可用的API。請使用一個使用者空間替代方案。

這個API在v8.0.0中已經廢棄了,但是仍然可以使用,就是如果使用可能會出現類似警告。到v11.0.0版本才結束生命周期,也就是說如果再引用就會直接報錯,而不僅僅是警告。

詳見:http://nodejs.cn/api/deprecations.html#deprecations_dep0061_fs_syncwritestream,或者下面的截圖:

Hexo:[DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.

處理這個問題

hexo-deployer-git

插件問題

在hexo的github裡面有談到這個問題:https://github.com/hexojs/hexo/issues/2598,然而我發現這個issue的釋出日期是2017,已經過去挺久的了。裡面提到的主要是hexo核心插件:

hexo-deployer-git

的問題,這個插件還引用了這個廢棄的API,詳見https://github.com/hexojs/hexo/issues/2598#issuecomment-318248764。是以該插件進行了更新

https://github.com/hexojs/hexo-deployer-git/releases,v0.3.1這個版本就是更新這個問題的,更新日期也是2017年。

Hexo:[DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.

是以如果你是這之後安裝的,應該已經是這以後的版本了,這個插件已經不會出現該問題了。(注:你可以到

\Hexo\package.json

去看插件版本)

如果你是在這個時間之前安裝的,可以使用下面命名更新插件:

npm install [email protected] --save

,或者更新到現在的最新版

2.0.0

其他插件問題–通用處理方法

上面提到的這個插件,好像是談到最多的插件。但是如果這個插件已經更新到了

0.3.1

版本之後,還會出現這個問題,那就說明是還有其他插件還引用了這個已經被廢棄的API,我們可以通過debug模式檢視是哪個插件的問題,比如我的:

$ hexo s --debug
02:34:07.422 DEBUG Writing database to H:\Hexo/db.json
02:34:07.494 DEBUG Hexo version: 3.9.0
02:34:07.496 DEBUG Working directory: H:\Hexo\
02:34:08.261 DEBUG Config loaded: H:\Hexo\_config.yml
02:34:08.561 DEBUG Plugin loaded: hexo-baidu-url-submit
02:34:08.596 DEBUG Plugin loaded: hexo-deployer-git
02:34:08.971 DEBUG Plugin loaded: hexo-abbrlink
02:34:08.988 DEBUG Plugin loaded: hexo-generator-archive
02:34:09.017 DEBUG Plugin loaded: hexo-generator-baidu-sitemap
02:34:09.028 DEBUG Plugin loaded: hexo-generator-category
02:34:09.042 DEBUG Plugin loaded: hexo-generator-index
02:34:09.062 DEBUG Plugin loaded: hexo-generator-feed
02:34:09.474 DEBUG Plugin loaded: hexo-generator-json-content
02:34:09.491 DEBUG Plugin loaded: hexo-generator-sitemap
02:34:09.506 DEBUG Plugin loaded: hexo-generator-tag
02:34:10.537 DEBUG Plugin loaded: hexo-neat
02:34:10.540 DEBUG Plugin loaded: hexo-renderer-stylus
02:34:10.556 DEBUG Plugin loaded: hexo-renderer-ejs
02:34:10.940 DEBUG Plugin loaded: hexo-admin
(node:9248) [DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.
02:34:10.945 DEBUG Plugin loaded: hexo-renderer-markdown-it
           

我們可以看到是

hexo-admin

這個插件出現了問題,那麼怎麼處理呢?一般隻需要将該插件更新到最新版就可以了,如果發現還沒有處理問題,說明該插件沒有處理這個警告,那麼隻能是到github倉庫提issue或者pr了。

參考:

  • hexo(四)DeprecationWarning: fs.SyncWriteStream is deprecated
  • https://blog.csdn.net/resilient/article/details/86430228

繼續閱讀