question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Cannot generate documentation of a lazy loaded Angular app

See original GitHub issue
Overview of the issue

Whenever I try to generate the documentation, I receive this error: reason: Error: Could not find the node's symbol. I saw this error has been filed several times, it should be assessed to be honest.

Operating System, Node.js, npm, compodoc version(s)

OS: MacOS Node.js: 12.13.0 npm: 6.13.7 compodoc: 1.1.11

Angular configuration, a package.json file in the root folder
{
  "name": "PRIVATE",
  "version": "PRIVATE",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "test_cc": "ng test --code-coverage --source-map",
    "lint": "ng lint",
    "serve": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve --prod",
    "build_prod": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod",
    "commit:init": "git config --local commit.template ./tools/.git-commit-template.txt",
    "compodoc": "npx compodoc -p ./tsconfig.json"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.2.4",
    "@angular/cdk": "^8.1.4",
    "@angular/common": "^8.2.4",
    "@angular/compiler": "^8.2.4",
    "@angular/core": "^8.2.4",
    "@angular/forms": "^8.2.4",
    "@angular/material": "^8.1.4",
    "@angular/material-moment-adapter": "^8.1.4",
    "@angular/platform-browser": "^8.2.4",
    "@angular/platform-browser-dynamic": "^8.2.4",
    "@angular/pwa": "^0.803.9",
    "@angular/router": "^8.2.4",
    "@angular/service-worker": "^8.2.4",
    "@auth0/angular-jwt": "^2.1.2",
    "@ngrx/core": "^1.2.0",
    "@ngrx/effects": "^6.1.2",
    "@ngx-translate/core": "^10.0.2",
    "@ngx-translate/http-loader": "^3.0.1",
    "@swimlane/ngx-charts": "^12.0.1",
    "@swimlane/ngx-graph": "^6.1.0",
    "@turf/turf": "^5.1.6",
    "@types/jspdf": "^1.3.1",
    "angular-tree-component": "8.5.2",
    "core-js": "^2.6.9",
    "d3": "^5.11.0",
    "dexie": "^2.0.4",
    "fabric": "^3.4.0",
    "html2canvas": "^1.0.0-rc.3",
    "intl": "^1.2.5",
    "jquery": "^3.4.1",
    "jspdf": "^1.5.3",
    "moment": "^2.24.0",
    "ng2-dragula": "^2.1.1",
    "ngx-device-detector": "^1.3.19",
    "ngx-papaparse": "^4.0.4",
    "ngx-summernote": "^0.5.5",
    "ngx-toastr": "^9.2.0",
    "ngx-translate-multi-http-loader": "^3.0.0",
    "ngx-tui-image-editor": "^7.0.2",
    "ol": "^5.3.3",
    "rxjs": "^6.5.2",
    "snazzy-info-window": "^1.1.1",
    "stream": "0.0.2",
    "summernote": "^0.8.12",
    "timers": "^0.1.1",
    "tslib": "^1.10.0",
    "tui-image-editor": "^3.7.0",
    "xml-js": "^1.6.11",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.800.6",
    "@angular/cli": "~8.0.6",
    "@angular/compiler-cli": "^8.2.4",
    "@angular/language-service": "^8.2.4",
    "@types/jasmine": "^2.8.16",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^8.10.53",
    "acorn": "^6.3.0",
    "angular-tslint-rules": "^1.18.0",
    "codelyzer": "^5.0.1",
    "commitizen": "^4.0.3",
    "git-branch": "^2.0.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^3.1.4",
    "karma-chrome-launcher": "^2.2.0",
    "karma-coverage-istanbul-reporter": "^2.0.6",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "parcel-bundler": "^1.12.3",
    "shallow-render": "^8.2.1",
    "ts-loader": "6.2.1",
    "ts-node": "~5.0.1",
    "tslint": "^5.19.0",
    "tslint-config-airbnb": "^5.11.1",
    "typescript": "~3.4.5"
  },
  "config": {
    "commitizen": {
      "path": "./tools/.cz-config.js"
    }
  }
}

Compodoc installed globally or locally ?

globally

If possible sourcecode of the file where it breaks

All my *-routing.module.ts

If possible your terminal logs before the error
Unhandled Rejection at: Promise {
  <rejected> InvalidOperationError: Could not find the node's symbol.
      at InvalidOperationError.BaseError [as constructor] (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/BaseError.js:7:28)
      at new InvalidOperationError (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/InvalidOperationError.js:8:28)
      at Object.throwIfNullOrUndefined (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/helpers.js:96:15)
      at Identifier.Node.getSymbolOrThrow (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/compiler/common/Node.js:131:23)
      at RouterParserUtil.cleanFileDynamics (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:5668:18)
      at AngularDependencies.getSourceFileDecorators (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:8152:46)
      at /Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:7960:31
      at Array.map (<anonymous>)
      at AngularDependencies.getDependencies (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:7949:21)
      at CliApplication.Application.getDependenciesData (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:9498:40)
} reason: InvalidOperationError: Could not find the node's symbol.
    at InvalidOperationError.BaseError [as constructor] (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/BaseError.js:7:28)
    at new InvalidOperationError (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/InvalidOperationError.js:8:28)
    at Object.throwIfNullOrUndefined (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/helpers.js:96:15)
    at Identifier.Node.getSymbolOrThrow (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/compiler/common/Node.js:131:23)
    at RouterParserUtil.cleanFileDynamics (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:5668:18)
    at AngularDependencies.getSourceFileDecorators (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:8152:46)
    at /Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:7960:31
    at Array.map (<anonymous>)
    at AngularDependencies.getDependencies (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:7949:21)
    at CliApplication.Application.getDependenciesData (/Users/dimitrirodriguesoliveira/.nvm/versions/node/v12.13.0/lib/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:9498:40)
[12:16:13] Sorry, but there was a problem during parsing or generation of the documentation. Please fill an issue on github. (https://github.com/compodoc/compodoc/issues/new)
Motivation for or Use Case

Cannot generate the documentation

Reproduce the error

Use compodoc on any complex lazy-loading app

Related issues

Yes, many that are flagged as wontfix

Suggest a Fix

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:21 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
arthur-97commented, Jan 27, 2021

Compodoc does not understand lazy loading when written with an arrow function with parentheses (m) => m.MyModule.

  1. open node_modules/@compodoc/compodoc/dist/application-54cd2170.js
  2. look at row 5129
  3. replace
    /(['"]loadChildren['"]:)\(\)=>"import\((\\'|'|")([^'"]+?)(\\'|'|")\)\.then\(\w+?=>\S+?\.([^)]+?)\)(\\'|'|")/g;
    to
    /(['"]loadChildren['"]:)\(\)=>"import\((\\'|'|")([^'"]+?)(\\'|'|")\)\.then\(\(?\w+?\)?=>\S+?\.([^)]+?)\)(\\'|'|")/g;
3reactions
tsiegleauqcommented, Oct 5, 2020

the solution from @iamruslanbakirov works for me. Yet I don’t even know why.

The compodoc generator fails when using Routes (which is Angulars default route syntax) instead of Route[], greeting you with the following error.

[12:22:59] Analysing routes definitions and clean them if necessary
Unhandled Rejection at: Promise {
  <rejected> InvalidOperationError: Could not find the node's symbol.

What’s confusing about this is that in Angulars source code, Routes itself is simply: export declare type Routes = Route[]; (an array of Route-Objects)

However: Replacing all const routes: Routes with const routes: Route[] in all of your *-routing.module.ts files does the trick.

To me it looks like some serious bugs in compodoc. That all related issues are marked with wontfix makes this tool even more frustrating.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular lazy loading cannot find module weird issue
I tried with different path for the modules.module in app-routing.module.ts, but none of that solves the problem. If you guys need more code...
Read more >
Lazy-loading feature modules - Angular
Setting up a lazy-loaded feature module requires two main steps: Create the feature module with the Angular CLI, using the --route flag. Configure...
Read more >
NG8003: No directive found with export - Angular
Angular can't find a directive with {{ PLACEHOLDER }} export name. This is common with a missing import or a missing exportAs on...
Read more >
Creating libraries - Angular
ng new my-workspace --no-create-application cd my-workspace ng generate library ... Your library should supply documentation (typically a README file) for ...
Read more >
Ahead-of-time (AOT) compilation - Angular
There's no need to download the Angular compiler if the application is already compiled. The compiler is roughly half of Angular itself, so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found