typedoc2md / typedoc-plugin-markdown

A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
https://typedoc-plugin-markdown.org
MIT License
725 stars 177 forks source link

[warning] TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. #676

Closed sthyagarajan closed 2 months ago

sthyagarajan commented 3 months ago

What package is the bug related to?

typedoc-plugin-markdown

Describe the issue

[warning] TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. The above warning prevents the instanceof checks for DeclarationReflection to fail and no docs are generated, if I remove plugin it works but obviously I like to get my MD file

TypeDoc configuration

{ "entryPoints": [ "src/index.ts" ], "entryPointStrategy": "expand", "excludePrivate": false, "excludeProtected": false, "excludeExternals": true, "out": "./docs", "hideGenerator": true, "disableSources": true, "navigationLinks": { "Home": "~~my url~ REDACTED" }, "expandObjects": true, "expandParameters": true, "plugin": [ "typedoc-plugin-zod", "typedoc-plugin-markdown" ], "excludeNotDocumented": false, "excludeNotDocumentedKinds": [ "Variable" ], "exclude": ["/node_modules/"] }

Expected behavior

Expectation is it will create MD files of all my classes under docs folder that can be hosted as github pages

tgreyuk commented 3 months ago

Unfortunately I am unable to debug this with the required information. I assume your setup isn't available on a public repo?

sthyagarajan commented 3 months ago

Unfortunately I am unable to debug this with the required information. I assume your setup isn't available on a public repo?

yes unfortunately nope, what do you need, I get the above warning as I run yarn docs and I see multiple versions of typedoc in node_modules coming from plugin and a direct dependency

tgreyuk commented 3 months ago

Typedoc is only a peer dependency. Do you get the same warning in the markdown plugin is the only plugin if the plugins list?

sthyagarajan commented 3 months ago

If I remove mardown plugin, typedoc gets generated obviously as HTML

tgreyuk commented 3 months ago

If I remove mardown plugin, typedoc gets generated obviously as HTML

Yes "obviously" it does. I meant do you get the warning if its the only plugin ie: plugins: ['typedoc-plugin-markdown']. I noticed that the zod plugin was in the list so i'm wondering if different peer dependancy versions might be causing the issue.

sthyagarajan commented 3 months ago

Yes

 yarn docs           
yarn run v1.22.10
$ rm -rf docs/api && typedoc -githubPages false
[info] Loaded plugin typedoc-plugin-markdown
[warning] TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. The loaded paths are:
        /Users/<username>/node_modules/typedoc
        /Users/<username>/node_modules/typedoc
[info] Documentation generated at ./docs
[warning] Found 0 errors and 1 warnings
    "plugin": [
        "typedoc-plugin-markdown"
    ]
tgreyuk commented 3 months ago

It seems that TypeDoc is being installed twice in your node modules, but typedoc is only a peer dependency of this plugin. Without an reproducable example to test against I don't think any progress can be made on this one.

tgreyuk commented 2 months ago

This bug is most likely related to this:

Note: If you install globally, be aware that npm/cli#7057 means that plugins and themes will get their own installation of TypeDoc unless you use the --legacy-peer-deps flag. This will break many plugins and cause warnings from TypeDoc.

See: https://typedoc.org/guides/installation/#requirements

I don't believe there is anything that can be done on the plugin side.