前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >关于解决Hexo上传时出现errorSpawn错误的详细说明

关于解决Hexo上传时出现errorSpawn错误的详细说明

作者头像
CtrlX
发布2022-08-10 20:10:16
1.4K0
发布2022-08-10 20:10:16
举报
文章被收录于专栏:C++核心编程C++核心编程

是什么:

错误展示: error:spawn failed... fatal: cannot lock ref 'HEAD': unable to resolve reference HEAD: Invalid argument error: src refspec error: src refspec HEAD does not match any.

为什么:

问题大多是因为git 进行push或者hexo d的时候改变了一些.deploy_git文件下的内容。

怎么做:

  1. 关键:删除.deploy_git文件夹; git config --global core.autocrlf false
  2. 之后:终端blog目录下使用管理员权限执行: hexo clean && hexo g hexo deploy

运行后问题解决

注意:问题可能会重复出现,只需再次删除.deploy_git后重新运行即可。

常见错误汇总

warning: LF will be replaced by CRLF in js/utils.js.

解决方法

git config –global core.autocrlf false

无法加载文件 C:\Users\10186\AppData\Roaming\npm\hexo.ps1,因为在此系统上禁止运行脚本

解决方法: 按下win+s输入powershell。然后右键以管理员身份运行。 然后输入set-ExecutionPolicy RemoteSigned命令

升级主题方法

升級方法:在主題目錄下,運行git pull

升级 Hexo

进入 Hexo 的目录,检查一下有哪些 Package 已经过期了:

$ npm outdated Package Current Wanted Latest Location eslint 6.1.0 6.8.0 7.4.0 hexo-site hexo 3.9.0 3.9.0 4.2.1 hexo-site hexo-deployer-git 1.0.0 1.0.0 2.1.0 hexo-site hexo-deployer-rsync 0.1.3 0.1.3 1.0.0 hexo-site hexo-generator-archive 0.1.5 0.1.5 1.0.0 hexo-site hexo-generator-category 0.1.3 0.1.3 1.0.0 hexo-site hexo-generator-feed 1.2.2 1.2.2 2.2.0 hexo-site hexo-generator-index 0.2.1 0.2.1 1.0.0 hexo-site hexo-generator-sitemap 1.2.0 1.2.0 2.0.0 hexo-site hexo-generator-tag 0.2.0 0.2.0 1.0.0 hexo-site hexo-renderer-ejs 0.3.1 0.3.1 1.0.0 hexo-site hexo-renderer-marked 1.0.1 1.0.1 3.0.0 hexo-site hexo-renderer-stylus 0.3.3 0.3.3 1.1.0 hexo-site hexo-server 0.3.3 0.3.3 1.0.0 hexo-site hexo-symbols-count-time 0.6.0 0.6.3 0.7.1 hexo-site 根据上面的信息修改一下 package.json 文件:

{ “name”: “hexo-site”, “version”: “0.0.0”, “private”: true, “hexo”: { “version”: “4.2.1” }, “dependencies”: { “hexo”: “^4.2.0”, “hexo-deployer-git”: “^2.1.0”, “hexo-deployer-rsync”: “^1.0.0”, “hexo-generator-archive”: “^1.0.0”, “hexo-generator-category”: “^1.0.0”, “hexo-generator-feed”: “^2.2.0”, “hexo-generator-index”: “^1.0.0”, “hexo-generator-search”: “^2.4.0”, “hexo-generator-seo-friendly-sitemap”: “0.0.25”, “hexo-generator-sitemap”: “^2.0.0”, “hexo-generator-tag”: “^1.0.0”, “hexo-renderer-ejs”: “^1.0.0”, “hexo-renderer-marked”: “^3.0.0”, “hexo-renderer-stylus”: “^1.1.0”, “hexo-server”: “^1.0.0”, “hexo-symbols-count-time”: “^0.7.1” } }

反正就是根据 npm 反馈的版本号对应修改一下就好了。全部改好了以后,就 npm 更新一下:

$ npm install –save 为了减少不必要的垃圾和冲突,我在执行上述命令之前删除了 node_modules 目录:

$ rm -fr node_modules

更新 Hexo CLI

接着运行,发现 Hexo 命令行显示乱码(换行不正确),检查一下有无新版本:

$ npm outdated -g Package Current Wanted Latest Location hexo-cli 2.0.0 2.0.0 3.1.0 global 嗯,果然是有新版本的,升级:

npm install hexo-cli -g npm WARN deprecated hexo-bunyan@2.0.0: Please see https://github.com/hexojs/hexo-bunyan/issues/17 /usr/local/bin/hexo -> /usr/local/lib/node_modules/hexo-cli/bin/hexo

  • hexo-cli@3.1.0 added 23 packages from 10 contributors, removed 196 packages and updated 32 packages in 9.859s 重新运行 Hexo 命令,一切正常。

Warning: Accessing non-existent property xxxx of module exports inside circular dependency

采用低版本nodejs

Cannot GET/xxx

1.判断public目录下xxx文件是否存在。 (我的错误是 Cannot GET /,因此在public目录下寻找index.html是否存在。)

2.如果说index.html不存在,那么执行hexo c,hexo g重新生成一次,回到步骤1。

3.步骤2执行完后index.html仍不存在,执行npm audit fix,查看是否少了什么组件,通过npm install hexo-xxx-xxx 安装即可。 (我的hexo缺少了hexo-generator-index组件,因此执行npm install hexo-generator-index即可)

4.步骤3完成之后,执行hexo c,hexo g重新生成静态文件。

hexo YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key

当输入hexo s -g发布博文并预览时出现下面的提示: FATAL YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key (386:12) 报错信息是提示hexo的yml配置文件 冒号后面少了空格 解决方案:到提示行将对应的空格补上即可

WARN Deprecated config detected: “use_date_for_updated” is deprecated, please use “updated_option” instead.

编辑根目录的 _config.yml 文件 , 把 use_date_for_updated 值改为 updated_option

拷贝原博客文件

必须拷贝文件: ├──_config.yml ├── theme ├── scaffolds #文章模板 ├── package.json #说明使用哪些包 ├── .gitignore #限定在提交的时候哪些文件可以忽略 └── source

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-07-30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 是什么:
  • 为什么:
  • 怎么做:
  • 常见错误汇总
    • warning: LF will be replaced by CRLF in js/utils.js.
      • 无法加载文件 C:\Users\10186\AppData\Roaming\npm\hexo.ps1,因为在此系统上禁止运行脚本
        • 升级主题方法
          • 升级 Hexo
            • 更新 Hexo CLI
              • Warning: Accessing non-existent property xxxx of module exports inside circular dependency
                • Cannot GET/xxx
                  • hexo YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key
                    • WARN Deprecated config detected: “use_date_for_updated” is deprecated, please use “updated_option” instead.
                      • 拷贝原博客文件
                      领券
                      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档