docsifyjs / docsify

🃏 A magical documentation site generator.

Home Page:https://docsify.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Import error

jpage-godaddy opened this issue · comments

Bug Report

docsify-server-renderer does not declare strip-indent as a dependency. Thus, if the install tree has other versions of strip-indent, like version 4.0.0, we get this error:

var stripIndent = _interopDefault(require('strip-indent'));
                                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/jpage/Code/<myrepo>/node_modules/strip-indent/index.js from /home/jpage/Code/<myrepo>/node_modules/docsify-server-renderer/build.js not supported.
Instead change the require of index.js in /home/jpage/Code/<myrepo>/node_modules/docsify-server-renderer/build.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/jpage/Code/<myrepo>/node_modules/docsify-server-renderer/build.js:13:35)
    at Object.<anonymous> (/home/jpage/Code/<myrepo>/node_modules/docsify-cli/lib/commands/start.js:5:18)
    at Object.<anonymous> (/home/jpage/Code/<myrepo>/node_modules/docsify-cli/lib/index.js:4:10)
    at Object.<anonymous> (/home/jpage/Code/<myrepo>/node_modules/docsify-cli/bin/docsify:8:13) {
  code: 'ERR_REQUIRE_ESM'
}

Steps to reproduce

  1. Install docsify-cli in a project that has strip-indent@^4.0.0 installed to the top of node_modules.
  2. Run docsify init

Current behaviour

The above runtime error occurs

Expected behaviour

No error. docsify-server-renderer should install strip-indent@3 nested under its own node_modules so that it requires the correct version of that dependency.

Other relevant information

  • Docsify version: 4.13.1
  • Bug still occurs when all/other plugins are disabled?

  • Docsify plugins (if the bug happens when plugins enabled, please try to isolate the issue):

It appears the problem is that it's loading the wrong version of strip-indent. I have it twice in my dependency tree, one that's 3.0.0 as a dependency of docsify and one that's 4.0.0 for an unrelated dependency. When docsify-server-renderer loads strip-indent, it's resolving to the one that floated to the top level of my node_modules which happened to be 4.0.0 instead of 3.0.0. Basically, the problem is that docsify-server-renderer doesn't have strip-indent listed as dependency, so it doesn't have a way of guaranteeing that the correct version resolves. I don't see where the dependencies of docsify-server-renderer are maintained; I can't even figure out where that package lives.

Hi @jpage-godaddy , thx for your report and sorry for the delay to reply.
We already plan to remove the docsify-server-renderer out of the main repo (it has been removed from develop branch now).
Because we involve more changes into the next release now, the new release date may take time to discuss with members.
Sorry for the inconvenient.