(已经解决,错误的原因主要是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-pagesrepository路径:
之前在_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: git@github.com: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目录部署到GitHubhexo help# 查看帮助hexo version#查看Hexo的版本