hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
38.83k stars 4.76k forks source link

How can I install the old version of the hexo since 4.0.0 version has some problems with theme icarus? #3904

Closed Icecream-blue-sky closed 4 years ago

Icecream-blue-sky commented 4 years ago

When I install the latest versions of hexo and icarus,some cofusing problems occurs while old versions don't.So I think it must be the problems of new version.But I don't know how to roll back to the old version(when I use commands like 'npm install hexo@3.9.0 --save',it makes my website 404) or
just install the old versions.While using npm install -g hexo-cli, it always install the latest hexo versions.Does anyone know how to solve my problem?Thks

SukkaW commented 4 years ago

If you are facing problems when using icarus, you should open an issue at icarus, not here.

Hexo 4.0.0 has introduced some Breaking Changes that is not backward compatible. But still, those changes are not related to users, they are only important to theme developers.

Icecream-blue-sky commented 4 years ago

If you are facing problems when using icarus, you should open an issue at icarus, not here.

Hexo 4.0.0 has introduced some Breaking Changes that is not backward compatible. But still, those changes are not related to users, they are only important to theme developers.

Actually,I just come from icarus issue(someone there tell me it's the problem of hexo 4.0.0 and if I rollback problems will be solved).I guess my problems it's just like the version problems of hexo and next which is , when one updates,another sometimes occurs some confusing problems.Anyway, I am not accusing hexo 4.0.0. I just want to know if there some ways to rollback my version of hexo like 3.9.0 or 3.7.0.May be many problems(like some theme incompatibility issues) can be solved by this way.Thks for answer!

dailyrandomphoto commented 4 years ago

@Icecream-blue-sky I think this issue is caused by _config.yml. Try to comment out ignore:

# _config.yml

  # Include / Exclude file(s)
  ## include:/exclude: options only apply to the 'source/' folder
  include:
  exclude:
-  ignore:
+ # ignore:

or set some values.

  ignore:
+    - "**/node_modules/**"

then

hexo clean && hexo g
SukkaW commented 4 years ago

@dailyrandomphoto By default, ignore use [] as default value for past 2 years and the ignore hasn't been added in hexo-starter template until https://github.com/hexojs/hexo-starter/commit/db3bf716ad04593b4046c99b942a6e6d7dac70c0. For a user update from Hexo@3, there is no way he would run into problem about ignore options.

dailyrandomphoto commented 4 years ago

@SukkaW If left ignore: as an empty value in _config.yml, then hexo.config.ignore becomes null Box.ignore becomes [null].

[null] causes

TypeError: glob pattern string required
    at minimatch (/home/dev/hexojs/test-rollback/node_modules/minimatch/minimatch.js:94:11)
    at console.log.ignore.some .ignore.some.item (/home/dev/hexojs/test-rollback/node_modules/hexo/lib/box/index.js:108:21)
    at Array.some (<anonymous>)
    at Theme.Box._readDir (/home/dev/hexojs/test-rollback/node_modules/hexo/lib/box/index.js:108:39)
    at fs.stat.then.stats (/home/dev/hexojs/test-rollback/node_modules/hexo/lib/box/index.js:162:17)

https://github.com/hexojs/hexo/blob/3.9.0/lib/box/index.js#L108

On hexo@4.0.0, fixed this issue. https://github.com/hexojs/hexo/commit/8d83bdff7335ea82866a2b055f0a0287de8e844c#diff-b3aaacb52e0f3b66ef93e288eaa55fb2L33-L37

Edit: I just opened a PR to hexo-starter. https://github.com/hexojs/hexo-starter/pull/30

SukkaW commented 4 years ago

@dailyrandomphoto The null should be considered as an issue. I will label this issue as a bug and assign to @curbengh

curbengh commented 4 years ago

On hexo@4.0.0, fixed this issue. https://github.com/hexojs/hexo/commit/8d83bdff7335ea82866a2b055f0a0287de8e844c#diff-b3aaacb52e0f3b66ef93e288eaa55fb2L33-L37

The null should be considered as an issue. I will label this issue as a bug and assign to

Huh? Does the bug affect hexo@4 or master branch? Is https://github.com/hexojs/hexo/pull/3908 necessary?

I tested current master branch with null ignore:, and I didn't encounter any error.

curbengh commented 4 years ago

btw @Icecream-blue-sky, for https://github.com/ppoffice/hexo-theme-icarus/issues/567, I believe it's related to https://github.com/hexojs/hexo-util/issues/122, which has been fixed in hexo-util 1.6.0.

Can you try upgrading hexo-util?

package.json
  "hexo": "^4.0.0",
+  "hexo-util": "^1.6.1",

If that doesn't work, you can use bleeding edge version (temporarily),

package.json
-  "hexo": "^4.0.0",
+  "hexo": "hexojs/hexo",

Remember to remove node_modules/ folder and package-lock.json file (https://github.com/hexojs/hexo/issues/3904#issuecomment-562458028) before npm install.

dailyrandomphoto commented 4 years ago

Huh? Does the bug affect hexo@4 or master branch? Is #3908 necessary?

The main culprit of this issue is converting null to [null] .

  if (!Array.isArray(this.ignore)) {
    this.ignore = [this.ignore];
  }

It has been removed from hexo@4.0. (https://github.com/hexojs/hexo/commit/8d83bdff7335ea82866a2b055f0a0287de8e844c#diff-b3aaacb52e0f3b66ef93e288eaa55fb2L33-L37)

After some check, I think #3908 is not necessary.

dailyrandomphoto commented 4 years ago

Can you try upgrading hexo-util?

package.json
  "hexo": "^4.0.0",
+  "hexo-util": "^1.6.1",

If that doesn't work, you can use bleeding edge version (temporarily),

package.json
-  "hexo": "^4.0.0",
+  "hexo": "hexojs/hexo",

Remember to remove node_modules/ folder before npm install.

A simple way is

rm package-lock.json 
rm -rf node_modules/hexo-util/
npm install

To install a new version of dependencies, should delete package-lock.json .

dailyrandomphoto commented 4 years ago

After some check, I think #3908 is not necessary.

@SukkaW @curbengh I found a new issue and opened a PR. (#3910)

hexo g will fail if _config.yml set like these

ignore: 
  -   # <= null
ignore: 
  -   # <= null
  - /some/path/

or

ignore: 
  - '' # <= empty string
curbengh commented 4 years ago

After some check, I think #3908 is not necessary.

In #3908, I believe the null config is already handled much earlier, so #3908 is not really necessary.

But I do consider #3908 a good practice, thus I won't revert it.


hexo g will fail if _config.yml set like these

ignore: 
  -   # <= null
ignore: 
  -   # <= null
  - /some/path/

or

ignore: 
  - '' # <= empty string

Those examples are considered invalid config, not edge cases; thus, it's correct for current hexo to error out. The error can inform the user that the config is invalid, we shouldn't be too lenient on invalid config. As such, I consider #3910 to be unnecessary.


My understanding is that the null issue only affects <v4. Any newer fix won't be backported to older versions.

Icecream-blue-sky commented 4 years ago

@dailyrandomphoto 's method works well.With it I successfully rollback to 3.9.0 and solve the problems with back_to_top button in icarus.However, I'm still looking forward to the hexo 4.1.0 version if it can solve the link problems like back_to_top button([https://github.com/ppoffice/hexo-theme-icarus/issues/567#issue-531677345]) completely.Thks everyone!

curbengh commented 4 years ago

4.1.0 has just been released, have a try.