问题复现

在 Windows 下完成了hexo的部署后将其迁移到 macOS 下,大部分功能正常,但是运行hexo d时直接报错。(如下所示)

1
2
3
4
5
6
7
8
9
10
11
12
13
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No error
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/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': No error

at ChildProcess.<anonymous> (/users/rin/Blogfile\node_modules\hexo-util\lib\spawn.js:37:17)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at ChildProcess.cp.emit (/users/rin/Blogfile\node_modules\cross-spawn\lib\enoent.js:40:29)
at maybeClose (internal/child_process.js:920:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)

解决方案

替换为:

git@github.com:[yourgitname]/[yourgitname].github.io.git”

命令操作

1
hexo config deploy.repository git@github.com:[yourgitname]/[yourgitname].github.io.git

文件操作

1.打开hexo根目录下的_config.yml

2.修改其结尾为

1
2
3
4
deploy:
type: git
repository: git@github.com:[yourgitname]/[yourgitname].github.io.git
branch: main

3.再次运行hexo d,问题应该已经解决。

成功部署