vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.57k stars 4.76k forks source link

Hard coded reference to `node_modules` from `docs`? #3133

Open CanadianBeaver opened 1 year ago

CanadianBeaver commented 1 year ago

Bug report

Steps to reproduce

package.json:

{
  "scripts": {
    "dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vuepress dev ../../Articles/ --open",
    "build": "SET NODE_OPTIONS=--openssl-legacy-provider && vuepress build ../../Articles/"
  },
  "devDependencies": {
    "markdown-it-abbr": "^1.0.4",
    "markdown-it-footnote": "^3.0.3",
    "markdown-it-plantuml": "^1.4.1",
    "markdown-it-sub": "^1.0.0",
    "markdown-it-sup": "^1.0.0",
    "markdown-it-textual-uml": "^0.12.0",
    "vuepress": "^1.9.2"
  }
}

config.js:

module.exports = {
...
  markdown: {
    extendMarkdown: md => {
      md.use(require('markdown-it-sub'))
      md.use(require('markdown-it-sup'))
      md.use(require('markdown-it-footnote'))
      md.use(require('markdown-it-abbr'))
      md.use(require('markdown-it-plantuml'))
      md.use(require('markdown-it-textual-uml'))
    }
  }
}

Executing npm run dev or npm run build thrown exception (workdir is C:\Users\~~~\Website-Generators\vuepress):

npm run build
> build
> SET NODE_OPTIONS=--openssl-legacy-provider && vuepress build ../../Articles/

wait Extracting site metadata...
tip Apply theme @vuepress/theme-default ...
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/search (i.e. "@vuepress/plugin-search") ...
tip Apply plugin @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...
Error: Cannot find module 'markdown-it-sub'
Require stack:
- C:\Users\~~~\Articles\.vuepress\config.js
- C:\Users\~~~\Website-Generators\vuepress\node_modules\@vuepress\core\lib\node\loadConfig.js
- C:\Users\~~~\Website-Generators\vuepress\node_modules\@vuepress\core\lib\node\App.js
- C:\Users\~~~\Website-Generators\vuepress\node_modules\@vuepress\core\lib\index.js
- C:\Users\~~~\Website-Generators\vuepress\node_modules\vuepress\lib\registerCoreCommands.js
- C:\Users\~~~\Website-Generators\vuepress\node_modules\vuepress\cli.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at extendMarkdown (C:\Users\~~~\Articles\.vuepress\config.js:35:14)
    at afterInstantiate (C:\Users\~~~\Website-Generators\vuepress\node_modules\@vuepress\core\lib\node\createMarkdown.js:23:23)
    at module.exports (C:\Users\~~~\Website-Generators\vuepress\node_modules\@vuepress\markdown\index.js:125:23)
    at module.exports (C:\Users\~~~\Website-Generators\vuepress\node_modules\@vuepress\core\lib\node\createMarkdown.js:27:10)
    at App.process (C:\Users\~~~\Website-Generators\vuepress\node_modules\@vuepress\core\lib\node\App.js:113:21)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async build (C:\Users\~~~\Website-Generators\vuepress\node_modules\@vuepress\core\lib\index.js:26:3)

What is expected?

World peace

What is actually happening?

Project can not be build, throws an exception

Other relevant information

CanadianBeaver commented 1 year ago

Shortly: VuePress are looking for a folder of node_modules for getting markdown extensions defined in config.js:. But instead of looking node_modules folder in working dir, VuePress is looking node_modules folder in docs\...\node_modules.