Hexo搭建出現的錯誤

(已經解決,錯誤的原因主要是github的賬戶驗證出現了問題,不是hexo工具本身的問題,我們換種思路,將git提交方式由每次驗證賬戶換成免登陸,結果hexo d提交不會出錯了,免登陸請看我的另一篇博客)

錯誤如下:

cs/troubleshooting.html
Error: bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': Invalid argument


    at ChildProcess.<anonymous> (D:\Github\myblog\node_modules\hexo-util



在使用hexo d 提交我們的博客時,提示我們github的用戶名錯誤,在網上查了很多方法也不行,在簡書上面看到着方法:

解決

hexo d的作用是將博客靜態頁面提交到遠程倉庫,這個功能是通過hexo-deployer-git工具實現的,就想着可能是這個工具出了問題,試着卸載重裝了這個工具,不過還是會報錯。自然就想到了一個辦法:在hexo g生成靜態頁面之後,不使用hexo d提交,而是直接通過git命令行提交。不過這個方法有點繁瑣。每次hexo clean之後,都需要創建本地倉庫,重新關聯遠程倉庫。後來在hexo的github issues找着了一個和上面發生的錯誤相似的issueProblem with deployment on GitHub #1495, 受到歪果仁朋友的啓發,將我的git倉庫地址改爲ssh格式的路徑,使用hexo d命令就可以成功部署了。下面給出這兩個辦法的詳細步驟

git命令行提交

先切換到publish目錄下 依次執行下面的命令

    git init 
    git remote add origin https://github.com/hellofriday/hellofriday.github.com.git
    git add .
    git commit -m 'add blog'
    git push -f origin master:gh-pages

repository路徑:

之前在_config.yml文件中配置的git遠程倉庫地址使用的是https路徑:

    deploy:
      type: git
      repository: https://github.com/hellofriday/hellofriday.github.com.git
      branch: gh-pages

將路徑改成ssh格式

    deploy:
      type: git
      #repository: https://github.com/hellofriday/hellofriday.github.com.git
      repository: [email protected]:hellofriday/hellofriday.github.com.git
      branch: gh-pages




這種方法是可以的,但是每次都要使用git來完成提交,hexo d依然報錯,暫時使用git的GUI工具來提交吧



常用命令

hexo new "postName" #新建文章 hexo new page "pageName" #新建頁面 hexo generate #生成靜態頁面至public目錄 hexo server #開啓預覽訪問端口(默認端口4000,'ctrl + c'關閉server) hexo deploy #將.deploy目錄部署到GitHub hexo help # 查看幫助 hexo version #查看Hexo的版本


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章