Typedoc: Uncaught TypeError: Cannot set property 'lunr' of undefined

Created on 21 Jun 2019  路  7Comments  路  Source: TypeStrong/typedoc

Expected Behavior

No errors when loading the documentation's index.html (and other pages of the generated documentation).

Actual Behavior

That error appears, search does not work

image

Steps to reproduce the bug

Generate documentation using,


typedoc.js,

module.exports = {
    "out": __dirname + "/doc",
    "json": __dirname + "/doc.json",
    "mode": "modules",
    "name": "type-mapping",
    "tsconfig": __dirname + "/tsconfig.json",
    "exclude": __dirname + "/+(node_modules|test|script)/**/*",
    "excludeNotExported": false,
};
console.log(module.exports);

Open the index.html on Chrome.

Environment

  • Typedoc version: master branch; dfb7207383bdd6a9b7e69271b18bb154b6fec7d9
  • Node.js version: v11.12.0
  • OS: Ubuntu 18.04
bug

Most helpful comment

The problem may stem from the bundler assuming all code is strict code, and the actual code may not expect to be bundled as a module (ES Modules are treated as strict mode).

All 7 comments

Same problem

It seems is related to the "use strict"; on the top of main.js file.
Removing it, seems to be working for me.

Removing "use strict"; from the very beginning of the generated assets/js/main.js did the trick for me too. Maybe there is some code trying to set global variables, but "use strict" prevents this. For example, try this in Chrome console:

function test() {
  "use strict"
  foo = 1
}

test()

console.log(foo) // foo is not defined

The problem may stem from the bundler assuming all code is strict code, and the actual code may not expect to be bundled as a module (ES Modules are treated as strict mode).

I believe this has been fixed on the master branch of typedoc-default-themes, the master branch here is still pointed to 738d24 while the latest commit is 56a1690. When running TypeDoc with the latest changes there, I don't see this error.

The typedoc-default-themes repo and typedoc repo being out of sync is pretty common, if you don't want to manually fix this every time you clone, I keep @gerrit0/typedoc synced up correctly with the latest changes on master.

@Gerrit0 I cannot refer your repo since I use plugin that depends on original repo.

This has been fixed with the release of 0.15.1

Was this page helpful?
0 / 5 - 0 ratings