How to solve FATAL: Unable to load template when using jsdoc?

817 views Asked by At

I am facing the issues reported here and here on GitHub. I am trying to add documentation for my Next.js code and following is my jsdoc config file.

{
  "tags": {
    "allowUnknownTags": true,
    "dictionaries": ["jsdoc", "closure"]
  },
  "source": {
    "include": [""],
    "exclude": ["node_modules"],
    "includePattern": "\\.(jsx|js|ts|tsx)$",
    "excludePattern": "(^|\\/|\\\\)_"
  },
  "plugins": [
    "node_modules/better-docs/typescript",
    "plugins/markdown",
    "jsdoc-mermaid",
    "node_modules/better-docs/component",
    "node_modules/better-docs/category",
    "node_modules/better-docs/typedef-import"
  ],
  "templates": {
    "cleverLinks": false,
    "search": true,
    "default": {
      "name": "Frontend Docs",
      "title": "Frontend Docs"
    },
    "better-docs": {
      "name": "Frontend Docs",
      "title": "Frontend Docs"
    }
  },
  "opts": {
    "encoding": "utf8",
    "destination": "docs/",
    "readme": "README.md",
    "recurse": true,
    "verbose": true,
    "template": "./node_modules/better-docs"
  }
}

With the above configuration, jsdoc generates the documentation but without the plugins. When I change "template": "./node_modules/better-docs" (last line) to "template": "better-docs", I get this error:

FATAL: Unable to load template: Cannot find module 'C:\Users\...\node_modules\.pnpm\[email protected][email protected][email protected][email protected]\node_modules\better-docs\publish.js/publish'
1

There are 1 answers

1
M.Mahdi Saeidi On

Actually, you should use "template": "./node_modules/better-docs" for better-docs. However, I encountered the same issue when using "template": "./node_modules/better-docs", and it showed the following error:

FATAL: Unable to load template: Cannot find module 'taffydb'
Require stack:
- C:\----\----\node_modules\better-docs\publish.js
- C:\----\----\node_modules\jsdoc\cli.js
- C:\----\----\node_modules\jsdoc\jsdoc.js

To fix this error, I used yarn add -D taffydb, and it resolved the issue.

Hope it's helpful.