vuepress / vuepress-community

:bulb: Community supported ecosystem for VuePress
https://vuepress-community.netlify.app
MIT License
81 stars 62 forks source link

[Question] An error was encounted in plugin "smooth-scroll" #1

Closed Mister-Hope closed 4 years ago

Mister-Hope commented 4 years ago

Environment

My theme package:

  "dependencies": {
    "@vuepress/plugin-medium-zoom": "^1.2.0",
    "@vuepress/plugin-pwa": "^1.2.0",
    "leancloud-storage": "^3.15.0",
    "markdown-it-footnote": "^3.0.2",
    "markdown-it-sub": "^1.0.0",
    "markdown-it-sup": "^1.0.0",
    "moment": "^2.24.0",
    "screenfull": "5.0.0",
    "valine": "^1.3.10",
    "vuepress": "^1.2.0",
    "vuepress-plugin-clean-urls": "^1.0.3",
    "vuepress-plugin-copyright": "^1.0.2",
    "vuepress-plugin-flowchart": "^1.4.3",
    "vuepress-plugin-mathjax": "^1.2.8"
  },
  "devDependencies": {
    "eslint": "^6.5.1",
    "eslint-plugin-vue": "^5.2.3"
  }

My docs:

  "dependencies": {
    "vuepress": "^1.2.0"
  },
  "devDependencies": {
    "@vuepress/plugin-blog": "^1.4.0",
    "eslint": "^6.5.1",
    "eslint-plugin-vue": "^5.2.3",
    "vuepress-plugin-named-chunks": "^1.0.2",
    "vuepress-theme-hope": "0.0.9-alpha1"
  }

Win10 1903 Node 10.16.3

What's your question?

After update to version 1.2.0, I removed smooth-scroll from my own theme, and add smoothScroll: true in my themeConfig, and I saw an error.

wait Extracting site metadata...
tip Apply theme vuepress-theme-hope (extends @vuepress/theme-default) ...
warning An error was encounted in plugin "smooth-scroll"
tip Apply plugin container (i.e. "vuepress-plugin-container") ...
tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
tip Apply plugin @vuepress/active-header-links (i.e. "@vuepress/plugin-active-header-links") ...
tip Apply plugin @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...
tip Apply plugin copyright (i.e. "vuepress-plugin-copyright") ...
tip Apply plugin flowchart (i.e. "vuepress-plugin-flowchart") ...
tip Apply plugin @vuepress/last-updated (i.e. "@vuepress/plugin-last-updated") ...
tip Apply plugin @vuepress/pwa (i.e. "@vuepress/plugin-pwa") ...
tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
tip Apply plugin @vuepress/medium-zoom (i.e. "@vuepress/plugin-medium-zoom") ...
tip Apply plugin mathjax (i.e. "vuepress-plugin-mathjax") ...
tip Apply plugin named-chunks (i.e. "vuepress-plugin-named-chunks") ...

while the smoth scroll featrue doesn't work.

This error will disappear after I rolled back to V1.1.0, and enable it by my own.

I am curious about it. I think the reason is that I have build or wrote something conflict with it.


Now I am very confused, because this error seems to be trigged at @vuepress/core and I am not familar with it. And I also don't have any infomation about with file or which line caused this error.

In a word, I don't know where to start debuging my code..... :cry:

If anyone can provide me some helps or opinions how can I debug this error, I will be very grateful.

meteorlxy commented 4 years ago

smoothScroll: true is only a feature of default theme, not @vuepress/core.

If you are building your own theme, you need to introduce vuepress-plugin-smooth-scroll yourself.

Mister-Hope commented 4 years ago

Why not have a more carefully look before closing it? I fell a little offend while you did that.

After all now it's not a vupress offical plugin, while under your repo.

tip Apply theme vuepress-theme-hope (extends @vuepress/theme-default) ...

My theme extends it, I have figure out the error ,see #1943

This error seems to be casused by wrong dependecy trees.


Besides I was just talking about who passed this error message ---@vuepress/code

Mister-Hope commented 4 years ago

You can see my package.json and package-lock.json at Here

{
  "name": "blog",
  "version": "1.0.0",
  "description": "个人博客",
  "scripts": {
    "serve": "vuepress dev src",
    "cleanServe": "vuepress dev src --no-cache",
    "build": "vuepress build src",
    "test": "echo \"Warning: no test specified\" && exit 0"
  },
  "author": "Mr.Hope",
  "license": "MIT",
  "keywords": [
    "vuepress",
    "personal-blog"
  ],
  "dependencies": {
    "vuepress": "^1.2.0"
  },
  "devDependencies": {
    "@vuepress/plugin-blog": "^1.4.0",
    "eslint": "^6.5.1",
    "eslint-plugin-vue": "^5.2.3",
    "vuepress-plugin-named-chunks": "^1.0.2",
    "vuepress-theme-hope": "0.0.10-alpha1"
  }
}

Npm put the smooth-scroll plugin under @vuepress/default-theme, and I can't figure out why.

meteorlxy commented 4 years ago

I personally don't suggest to use theme extending.

For now you can add smooth-scroll plugin to your theme's / blog's dependencies to solve the problem

Mister-Hope commented 4 years ago

I fixed it by install vuepress first(only) and then other packages one by one and there is no more wrong dependency trees :cry:

I took some times searching reason on the internet, but I didn't find out why.

Mister-Hope commented 4 years ago

Isn't npm supposed to generate the same tree when same dependency installed? QAQ

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.