ppoffice / hexo-component-inferno

A collection of Inferno.js layout components and utility scripts for Hexo
https://ppoffice.github.io/hexo-component-inferno/
24 stars 30 forks source link

Error: EISDIR: illegal operation on a directory, read. Package hexo-component-inferno is not installed. #46

Closed GanZhiXiong closed 2 years ago

GanZhiXiong commented 2 years ago

问题描述

因为我想改些代码,所以先 fork 这个仓库,然后在我的博客 icarus 主题下安装我 fork 的这个仓库,执行 hexo g 报错 Error: EISDIR: illegal operation on a directory, read

复现步骤

  1. fork 该仓库。
  2. cd 到博客主题 icarus 目录下。
  3. npm 安装我刚 fork 的该仓库。
    
    # gan @ ganzhixiongdeMac-Studio in ~/Documents/blog/themes/icarus on git:master x [13:14:32] 
    $ npm install --save ganzhixiong/hexo-component-inferno

changed 1 package in 43s

75 packages are looking for funding run npm fund for details

4. cd 到 hexo 博客根目录,执行 `hexo g` 和 `hexo s`。
```bash
# gan @ ganzhixiongdeMac-Studio in ~/Documents/blog on git:master x [13:19:26] 
$ hexo g
INFO  Validating config
ERROR {
  err: [Error: EISDIR: illegal operation on a directory, read] {
    errno: -21,
    code: 'EISDIR',
    syscall: 'read'
  }
} Plugin load failed: %s hexo-component-inferno
Inferno is in development mode.
INFO  =======================================
 ██╗ ██████╗ █████╗ ██████╗ ██╗   ██╗███████╗
 ██║██╔════╝██╔══██╗██╔══██╗██║   ██║██╔════╝
 ██║██║     ███████║██████╔╝██║   ██║███████╗
 ██║██║     ██╔══██║██╔══██╗██║   ██║╚════██║
 ██║╚██████╗██║  ██║██║  ██║╚██████╔╝███████║
 ╚═╝ ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝
=============================================
INFO  === Checking package dependencies ===
ERROR Package hexo-component-inferno is not installed.
ERROR Please install the missing dependencies your Hexo site root directory:
ERROR npm install --save hexo-component-inferno@github:ganzhixiong/hexo-component-inferno
ERROR or:
ERROR yarn add hexo-component-inferno@github:ganzhixiong/hexo-component-inferno

# gan @ ganzhixiongdeMac-Studio in ~/Documents/blog on git:master x [13:19:32] C:255
$ hexo s
INFO  Validating config
Inferno is in development mode.
ERROR {
  err: [Error: EISDIR: illegal operation on a directory, read] {
    errno: -21,
    code: 'EISDIR',
    syscall: 'read'
  }
} Plugin load failed: %s hexo-component-inferno
INFO  =======================================
 ██╗ ██████╗ █████╗ ██████╗ ██╗   ██╗███████╗
 ██║██╔════╝██╔══██╗██╔══██╗██║   ██║██╔════╝
 ██║██║     ███████║██████╔╝██║   ██║███████╗
 ██║██║     ██╔══██║██╔══██╗██║   ██║╚════██║
 ██║╚██████╗██║  ██║██║  ██║╚██████╔╝███████║
 ╚═╝ ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝
=============================================
INFO  === Checking package dependencies ===
ERROR Package hexo-component-inferno is not installed.
ERROR Please install the missing dependencies your Hexo site root directory:
ERROR npm install --save hexo-component-inferno@github:ganzhixiong/hexo-component-inferno
ERROR or:
ERROR yarn add hexo-component-inferno@github:ganzhixiong/hexo-component-inferno
GanZhiXiong commented 2 years ago

搜索得知,是因为从 fork 仓库安装的 hexo-component-inferno 不包含 build 后的文件导致的。 于是执行如下步骤:

  1. 对 fork 的仓库,创建一个带有 build 后的文件的分支。

    $ git checkout -b useLocally
    Switched to a new branch 'useLocally'
  2. 注释 .gitignore 文件中从 build 输出的文件夹 lib。

  3. 推送到远程分支。

  4. 使用如下命令安装带有 build 输出文件夹的分支。

    npm install --save hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#useLocally

执行 hexo g 报了一个和之前不一样的错误:

$ hexo g
INFO  Validating config
Inferno is in development mode.
INFO  =======================================
 ██╗ ██████╗ █████╗ ██████╗ ██╗   ██╗███████╗
 ██║██╔════╝██╔══██╗██╔══██╗██║   ██║██╔════╝
 ██║██║     ███████║██████╔╝██║   ██║███████╗
 ██║██║     ██╔══██║██╔══██╗██║   ██║╚════██║
 ██║╚██████╗██║  ██║██║  ██║╚██████╔╝███████║
 ╚═╝ ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝
=============================================
INFO  === Checking package dependencies ===
ERROR Package hexo-component-inferno's version (1.1.0) does not satisfy the required version (github:ganzhixiong/hexo-component-inferno#useLocally).
ERROR Please install the missing dependencies your Hexo site root directory:
ERROR npm install --save hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#useLocally
ERROR or:
ERROR yarn add hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#useLocally
GanZhiXiong commented 2 years ago

@ppoffice 有劳大神有空看看哈,非常感谢。

ppoffice commented 2 years ago

不要在icarus目录下安装,在博客根目录安装试试。或者你fork的仓库新建一个版本号tag,npm安装那个tag而不是useLocal。

GanZhiXiong commented 2 years ago

在博客根目录安装还是一样的。稍后我将尝试安装 fork 的 tag 版本。

# gan @ ganzhixiongdeMac-Studio in ~/Documents/blog on git:master x [20:23:50] 
$ npm install --save hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#useLocally

added 2 packages in 35s

29 packages are looking for funding
  run `npm fund` for details

# gan @ ganzhixiongdeMac-Studio in ~/Documents/blog on git:master x [20:25:05] 
$ hexo g                                                                                        
INFO  Validating config
Inferno is in development mode.
INFO  =======================================
 ██╗ ██████╗ █████╗ ██████╗ ██╗   ██╗███████╗
 ██║██╔════╝██╔══██╗██╔══██╗██║   ██║██╔════╝
 ██║██║     ███████║██████╔╝██║   ██║███████╗
 ██║██║     ██╔══██║██╔══██╗██║   ██║╚════██║
 ██║╚██████╗██║  ██║██║  ██║╚██████╔╝███████║
 ╚═╝ ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝
=============================================
INFO  === Checking package dependencies ===
ERROR Package hexo-component-inferno's version (1.1.0) does not satisfy the required version (github:ganzhixiong/hexo-component-inferno#useLocally).
ERROR Please install the missing dependencies your Hexo site root directory:
ERROR npm install --save hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#useLocally
ERROR or:
ERROR yarn add hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#useLocally
GanZhiXiong commented 2 years ago

新建了一个 tag 1.1.1 ,从 tag 版本安装也是一样的:

# gan @ ganzhixiongdeMac-Studio in ~/Documents/blog on git:master x [20:44:28] 
$ npm install --save hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#1.1.1

added 2 packages in 31s

29 packages are looking for funding
  run `npm fund` for details

# gan @ ganzhixiongdeMac-Studio in ~/Documents/blog on git:master x [20:45:04] 
$ hexo g
INFO  Validating config
Inferno is in development mode.
INFO  =======================================
 ██╗ ██████╗ █████╗ ██████╗ ██╗   ██╗███████╗
 ██║██╔════╝██╔══██╗██╔══██╗██║   ██║██╔════╝
 ██║██║     ███████║██████╔╝██║   ██║███████╗
 ██║██║     ██╔══██║██╔══██╗██║   ██║╚════██║
 ██║╚██████╗██║  ██║██║  ██║╚██████╔╝███████║
 ╚═╝ ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝
=============================================
INFO  === Checking package dependencies ===
ERROR Package hexo-component-inferno's version (1.1.0) does not satisfy the required version (github:ganzhixiong/hexo-component-inferno#useLocally).
ERROR Please install the missing dependencies your Hexo site root directory:
ERROR npm install --save hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#useLocally
ERROR or:
ERROR yarn add hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#useLocally
ppoffice commented 2 years ago

你icarus主题的package.json是怎样的?不行的话把scripts/index.js里面检查dependency 的那行注释掉就行了。

GanZhiXiong commented 2 years ago

果然注释掉 themes/icarus/scripts/index.js 下的 检查 dependency 就好了。

/**
 * Check if all dependencies are installed
 */
// require('../include/dependency')(hexo);

但是有一个错误提示

$ hexo s
INFO  Validating config
Inferno is in development mode.
ERROR {
  err: [Error: EISDIR: illegal operation on a directory, read] {
    errno: -21,
    code: 'EISDIR',
    syscall: 'read'
  }
} Plugin load failed: %s hexo-component-inferno
INFO  =======================================
 ██╗ ██████╗ █████╗ ██████╗ ██╗   ██╗███████╗
 ██║██╔════╝██╔══██╗██╔══██╗██║   ██║██╔════╝
 ██║██║     ███████║██████╔╝██║   ██║███████╗
 ██║██║     ██╔══██║██╔══██╗██║   ██║╚════██║
 ██║╚██████╗██║  ██║██║  ██║╚██████╔╝███████║
 ╚═╝ ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝
=============================================
INFO  === Checking theme configurations ===
INFO  === Registering Hexo extensions ===
GanZhiXiong commented 2 years ago
我的icarus主题的package.json文件 ```java { "name": "hexo-theme-icarus", "version": "5.0.0-rc.1", "author": "ppoffice ", "license": "MIT", "description": "A simple, delicate, and modern theme for Hexo", "keywords": [ "hexo", "theme", "icarus" ], "homepage": "https://github.com/ppoffice/hexo-theme-icarus", "repository": "https://github.com/ppoffice/hexo-theme-icarus.git", "bugs": { "url": "https://github.com/ppoffice/hexo-theme-icarus/issues" }, "engines": { "node": ">=12.4.0" }, "scripts": { "lint": "eslint --ext .js --ext .jsx --ext .json ." }, "devDependencies": { "eslint": "^8.6.0", "eslint-config-hexo": "^5.0.0", "eslint-plugin-json": "^3.0.0", "eslint-plugin-react": "^7.17.0" }, "dependencies": { "bulma-stylus": "0.8.0", "deepmerge": "^4.2.2", "hexo": "^6.0.0", "hexo-component-inferno": "github:ganzhixiong/hexo-component-inferno#useLocally", "hexo-log": "^3.0.0", "hexo-pagination": "^2.0.0", "hexo-renderer-inferno": "^0.1.3", "hexo-renderer-stylus": "^2.0.0", "hexo-util": "^2.4.0", "inferno": "^7.3.3", "inferno-create-element": "^7.3.3", "moment": "^2.22.2", "semver": ">=5.0.0" } } ```
ppoffice commented 2 years ago
"hexo-component-inferno": "github:ganzhixiong/hexo-component-inferno#useLocally",

你把这行改回去,然后npm install的时候别--save就不会检查错误了。

GanZhiXiong commented 2 years ago

你把这行改回去

改成什么啊? 改成"^1.1.0"吗?还是什么?

GanZhiXiong commented 2 years ago

解决从 fork 仓库安装 hexo-component-inferno 报错 ERROR Package hexo-component-inferno's version (1.1.0) does not satisfy the required version (github:ganzhixiong/hexo-component-inferno#useLocally). 的问题。

经过多次尝试,在博客根目录或主题根目录安装 fork 仓库的 hexo-component-inferno 都没有问题了。

在博客根目录下安装

  1. 先卸载主题的 hexo-component-inferno 依赖包。

    一定要卸载主题下的此依赖包,因为主题下的依赖包优先级大于其他目录。

    # gan @ ganzhixiongdeMac-Studio in ~/Documents/blog/themes/icarus on git:master x [10:20:41] 
    $ npm uninstall hexo-component-inferno
  2. 到博客的根目录下安装 fork 仓库的 hexo-component-inferno。

    # gan @ ganzhixiongdeMac-Studio in ~/Documents/blog on git:master x [10:26:28] C:1
    $ npm install ganzhixiong/hexo-component-inferno#useLocally   

在主题目录下安装

  1. 到主题的根目录下安装 fork 仓库的 hexo-component-inferno。

    # gan @ ganzhixiongdeMac-Studio in ~/Documents/blog/themes/icarus on git:master x [10:33:28] 
    $ npm install ganzhixiong/hexo-component-inferno#useLocally --save
  2. 执行 hexo shexo g都会报错:

    # gan @ ganzhixiongdeMac-Studio in ~/Documents/blog on git:master x [11:15:05] C:255
    $ hexo s
    INFO  Validating config
    Inferno is in development mode.
    INFO  =======================================
    ██╗ ██████╗ █████╗ ██████╗ ██╗   ██╗███████╗
    ██║██╔════╝██╔══██╗██╔══██╗██║   ██║██╔════╝
    ██║██║     ███████║██████╔╝██║   ██║███████╗
    ██║██║     ██╔══██║██╔══██╗██║   ██║╚════██║
    ██║╚██████╗██║  ██║██║  ██║╚██████╔╝███████║
    ╚═╝ ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝
    =============================================
    INFO  === Checking package dependencies ===
    ERROR Package hexo-component-inferno's version (1.1.2) does not satisfy the required version (github:ganzhixiong/hexo-component-inferno#useLocally).
    ERROR Please install the missing dependencies your Hexo site root directory:
    ERROR npm install --save hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#useLocally
    ERROR or:
    ERROR yarn add hexo-component-inferno@github:ganzhixiong/hexo-component-inferno#useLocally
  3. 注释掉 themes/icarus/scripts/index.js 下的 检查 dependency,即可解决。

    /**
    * Check if all dependencies are installed
    */
    // require('../include/dependency')(hexo);