Compodoc: [BUG] Error: Could not find the node's symbol.

Created on 31 Mar 2018  路  40Comments  路  Source: compodoc/compodoc

Overview of the issue

After upgrading to compodoc 1.1.1 from 1.0.9 I got the reason: Error: Could not find the node's symbol. error

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

compodoc: 1.1.1
node: 9.8.0
mac: High Sierra

Angular configuration, a package.json file in the root folder

Angular: 5.2.9

Compodoc installed globally or locally ?

locally installed compodoc

Motivation for or Use Case

Cannot generate docs anymore

Reproduce the error

npm script:
./node_modules/.bin/compodoc -p src/tsconfig.app.json -d ./docs -t --theme stripe --disableCoverage --hideGenerator -n \"My Documentation\"

Related issues

1.0.9 compodoc version was working well

Suggest a Fix
routing High Accepted ~1 hour Bug

Most helpful comment

I am currently seeing this issue as well when routes are being analyzed. This is the initial output of the error:

[19:28:02] Analysing routes definitions and clean them if necessary
Unhandled Rejection at: Promise {
  <rejected> Error: Could not find the node's symbol.

I believe that this is happening due to our usage of a TS string enumeration to define the path of the individual routes. For example: (redacting portions of the config)

Enum file:

export enum SomeEnum {
    SOME_ROUTE = 'some-route'
}

Routing Module Config:

import { SomeEnum } from './some-enum.enum';

const routes: Routes = [
    {
        path: '',
        component: SomeParentComponent,
        children: [
                    {
                        path: SomeEnum.SOME_ROUTE,
                        loadChildren: '/path/to/module/to/load#SomeModule'
                    }
        ]
    }
];

All 40 comments

Can i have a screenshot of your terminal ?
On which file did it breaks ?
If possible can i have the code of this file ?
thanks

Thanks for the quick reply @vogloblinsky see the output below. I hope this helps.
image

_Let me know if you need more details._ thanks your fix in advance.

I just started using compodoc, and get the same error.
In my case it was caused by the routes i was using. I had to comment the routes in both my app.module and another module and that was enough to make it work. Hope that helps.

@attilacsanyi thanks for the screenshot but i didn't see any reference to a file where Compodoc breaks. Is it one with routes definitions ?
@entrodus Is it possible to have an example of your routes ?

@vogloblinksky unfortunately this was the whole output, nothing more. My route definitions not changed between the working 1.0.9 and 1.1.1.
All my routes are lazyly loaded an have two router outlets.

I can confirm this happens to me as well.

I have pinned the issue, but it's trick to explain so i'll do my best.

The issue might be external, coming from ts-simple-ast

For me it happens whenever I use a function call expression where the function is on an object, e.g. myObj.functionCall(). If the function is used directly (functionCall()) it works fine.

Example:

In file utils.ts I export the following:

export const utils = {
  doWork(): any {
     return {};
  }
}

now in my app.routes.ts:

import { Routes } from '@angular/router';

import { utils } from './utils';

export const ROUTES: Routes = [
  {
    path: '',
    children: [
      {
        'some-path',
        loadChildren: 'apps/lazy-app#LazyAppModule',
        data: utils.doWork()
      }
    ]
  }
];

The above code will result in the error.

To fix it we just need to use doWork() directly so we add:

const { doWork } = utils;

and then use it directly:

data: doWork()

Now no errors.

I believe this is coming from ts-simple-ast but i'm not sure.

@shlomiassaf Thanks for the feedback. I will look that asap.

I am currently seeing this issue as well when routes are being analyzed. This is the initial output of the error:

[19:28:02] Analysing routes definitions and clean them if necessary
Unhandled Rejection at: Promise {
  <rejected> Error: Could not find the node's symbol.

I believe that this is happening due to our usage of a TS string enumeration to define the path of the individual routes. For example: (redacting portions of the config)

Enum file:

export enum SomeEnum {
    SOME_ROUTE = 'some-route'
}

Routing Module Config:

import { SomeEnum } from './some-enum.enum';

const routes: Routes = [
    {
        path: '',
        component: SomeParentComponent,
        children: [
                    {
                        path: SomeEnum.SOME_ROUTE,
                        loadChildren: '/path/to/module/to/load#SomeModule'
                    }
        ]
    }
];

Have the same issue:

Unhandled Rejection at: Promise {
TypeError: referencedDeclaration.getInitializerOrThrow is not a function
at RouterParserUtil.cleanFileDynamics

in log i see:

13 verbose stack Error: [email protected] compodoc: compodoc -p src/tsconfig.app.json
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at EventEmitter.emit (events.js:160:13)
13 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:160:13)
13 verbose stack at maybeClose (internal/child_process.js:943:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)

@vogloblinsky when are you going to release it to npm?
1.1.2 will be the new version I guess, right?

_Thanks your quick work again!_

In one or two hours ;)

Online !

Thanks @vogloblinsky but seems similar issue :(

Compodoc: 1.1.2 _(latest)_
Typescript version : 2.8.1
Node.js version : v9.11.1 _(latest newer than above)_
Operating system : macOS High Sierra

Unhandled Rejection at: Promise {
  <rejected> Error: Could not find the node's symbol.

Output, same as above
image

_Let me know how can I provide more help._

Arf
Compodoc breaks inside a function that clean Routes definition.
On which file did it breaks ?
On which Routing definition ?

How I know that @vogloblinsky ?
I just run from npm script, how can I see which route definition caused the break? :)

@attilacsanyi
You should have after the Operating system ... in your terminal lines listing the files parsed like in this travais logs : https://travis-ci.org/compodoc/compodoc-demo-todomvc-angular
After that you should also get Get dependencies data message, and after that for each files informations.
Did you get these lines ?

Ahh I need to remove the -t(silent) option from my script above almost forgot it :)
_The error appears after parsing my home-routing.module.ts lazy routes._
Additional details is that I have main routes which are lazily loaded and one of them contains the following additional lazy loaded modules in home-routing.module.ts:
image

Hope this helps @vogloblinsky

works for me now @vogloblinsky , thanks!

Let us know if you see what caused the issue @vogloblinsky in case of the nested lazy routes above.

_Thanks in advance, meanwhile I reverted back to the 1.0.9 working version._

In my case it happens when route paths are imported from some const

import { ROUTES_MAP } from './config';

{
     path: ROUTES_MAP.products,
     component: ParentInfoComponent
 }

When I comment all the paths declarations - it works. It is also the same on 1.0.9 version

@olehleskiv thanks for the example but imho these kind of problems have already been solved in #394.

Did you recognised the bug already @vogloblinsky? Thanks for the update.

I have the same error with latest build

"devDependencies": {
    "@angular/cli": "~1.7.4",
    "@compodoc/compodoc": "^1.1.2",
[17:59:57] parsing        : .***/src/app/app-routing.module.ts
[17:59:57] Analysing routes definitions and clean them if necessary
Unhandled Rejection at: Promise {
  <rejected> Error: Could not find the node's symbol. 

Routes in my case is const object, not Enum

export const ROUTES_MAP: any = {
  profile: 'dinside',
  settings: 'dinside/innstillinger',
  overview: 'oversikt',
...
}

And I don't have any lazy loading modules in app-routing.module

I am getting this error with compodoc v1.1.2 if I make use of the "data" property on a route with a values that come from an import:

For example, this gives an error:

library.ts

import * as dataSelectors from './data.selectors';
export { dataSelectors }

app-routing.module.ts

import { dataSelectors } from './library'

const routes: Routes = [
  {
    path: '',
    component: MyContainerComponent,
    data: {selector: dataSelectors.getAllDataItems }
}]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {}

But this does not give the error:

import { dataSelectors } from './library'

const mySelectors = {
  data: dataSelectors.getAllDataItems
};

const routes: Routes = [
  {
    path: '',
    component: MyContainerComponent,
    data: {selector: mySelectors.data }
}]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {}

Having the same issue on routing, compodoc v1.1.2.
Steps to reproduce:

  1. Clone https://github.com/ngx-rocket/starter-kit
  2. yarn global add @compodoc/compodoc
  3. compodoc -p src/tsconfig.app.json

I had the same issue, and it was definitely my routing. Compodoc works if I change my routes from

const appRoutes: Routes =
  environment.app === "internal"
    ? [
        {
          path: "",
          component: HomeComponent
        },

        // otherwise redirect to home
        { path: "**", redirectTo: "" }
      ]
    : [
        {
          path: "",
          component: HomeComponent,
          canActivate: [AuthGuard, LicenseAgreementGuard]
        },
        { path: "welcome", component: WelcomeComponent },
        {
          path: "agreement",
          component: LicenseAgreementComponent,
          canActivate: [AuthGuard]
        },

        // otherwise redirect to home
        { path: "**", redirectTo: "" }
      ];

export const routing = RouterModule.forRoot(appRoutes);

to

const appRoutes: Routes = [{ path: "**", redirectTo: "" }];
export const routing = RouterModule.forRoot(appRoutes);

.

Same problem here. We use string enums in our routes as well to prevent string literal duplication in routing setup and navigation services.

1.1.2

Typescript version : 2.8.1

Node.js version : v9.5.0

Operating system : Windows 10

The terminal error output:

[11:06:30] parsing        : C:/Develop/WorkSpaceJs/IoneJS/src/app/app.routing.ts
[11:06:30] Analysing routes definitions and clean them if necessary
Unhandled Rejection at: Promise {
  <rejected> Error: Could not find the node's symbol.
    at InvalidOperationError.BaseError [as constructor] (C:\Develop\WorkSpaceJs\IoneJS\node_modules\ts-simple-ast\dist\errors\BaseError.js:16:28)
    at new InvalidOperationError (C:\Develop\WorkSpaceJs\IoneJS\node_modules\ts-simple-ast\dist\errors\InvalidOperationError.js:17:28)
    at Object.throwIfNullOrUndefined (C:\Develop\WorkSpaceJs\IoneJS\node_modules\ts-simple-ast\dist\errors\helpers.js:96:15)
    at Identifier.Node.getSymbolOrThrow (C:\Develop\WorkSpaceJs\IoneJS\node_modules\ts-simple-ast\dist\compiler\common\Node.js:167:23)
    at RouterParserUtil.cleanFileDynamics (C:\Develop\WorkSpaceJs\IoneJS\node_modules\@compodoc\compodoc\dist\index-cli.js:1290:18)
    at Dependencies.getSourceFileDecorators (C:\Develop\WorkSpaceJs\IoneJS\node_modules\@compodoc\compodoc\dist\index-cli.js:5589:45)
    at C:\Develop\WorkSpaceJs\IoneJS\node_modules\@compodoc\compodoc\dist\index-cli.js:5416:27
    at Array.map (<anonymous>)
    at Dependencies.getDependencies (C:\Develop\WorkSpaceJs\IoneJS\node_modules\@compodoc\compodoc\dist\index-cli.js:5410:21)
    at CliApplication.Application.getDependenciesData (C:\Develop\WorkSpaceJs\IoneJS\node_modules\@compodoc\compodoc\dist\index-cli.js:7079:40) } reason: Error: Could not find the node's symbol.
    at InvalidOperationError.BaseError [as constructor] (C:\Develop\WorkSpaceJs\IoneJS\node_modules\ts-simple-ast\dist\errors\BaseError.js:16:28)
    at new InvalidOperationError (C:\Develop\WorkSpaceJs\IoneJS\node_modules\ts-simple-ast\dist\errors\InvalidOperationError.js:17:28)
    at Object.throwIfNullOrUndefined (C:\Develop\WorkSpaceJs\IoneJS\node_modules\ts-simple-ast\dist\errors\helpers.js:96:15)
    at Identifier.Node.getSymbolOrThrow (C:\Develop\WorkSpaceJs\IoneJS\node_modules\ts-simple-ast\dist\compiler\common\Node.js:167:23)
    at RouterParserUtil.cleanFileDynamics (C:\Develop\WorkSpaceJs\IoneJS\node_modules\@compodoc\compodoc\dist\index-cli.js:1290:18)
    at Dependencies.getSourceFileDecorators (C:\Develop\WorkSpaceJs\IoneJS\node_modules\@compodoc\compodoc\dist\index-cli.js:5589:45)
    at C:\Develop\WorkSpaceJs\IoneJS\node_modules\@compodoc\compodoc\dist\index-cli.js:5416:27
    at Array.map (<anonymous>)
    at Dependencies.getDependencies (C:\Develop\WorkSpaceJs\IoneJS\node_modules\@compodoc\compodoc\dist\index-cli.js:5410:21)
    at CliApplication.Application.getDependenciesData (C:\Develop\WorkSpaceJs\IoneJS\node_modules\@compodoc\compodoc\dist\index-cli.js:7079:40)

Our app.routing.ts has the same structure as previous posters.

Same here!

Some news?

I stucked at version 1.0.9 due to the same Error: Could not find the node's symbol. above. :)
Hopefully @vogloblinsky have something to fix the enum related stuff in router configs. _(was already fixed in the past as 1.0.9 version is working)_

Any news on that topic, @vogloblinsky?
I also use an enumeration for my route paths and cannot generate the documentation.

I am using version 1.1.3 from my local dependencies

Not ideal but I got this working by removing the Routes typing, example :

export coreRoutes : Routes = [ ... ]

Change to

export coreRoutes = [ ... ]

Thanks @WebStew , would be great if @vogloblinsky can solve it in a nice manner. ;-)

same problem
1.1.5

Typescript version :"~2.7.2

Node.js version : v8.11.3

Operating system : Windows 7

Unhandled Rejection at: Promise {
  <rejected> Error: Could not find the node's symbol.

I tried change

export routes: Routes = [ ... ]

to

export routes= [ ... ]

but it did not help=)

P.S. I'm using suggetion from https://github.com/compodoc/compodoc/issues/479 to include --disableRoutesGraph

Same problem
Compodoc version: 1.1.5
Typescript version : 2.9.1
Node.js version : v8.12.0
Operating system : Windows 10
\
\
We are using an enum in our route data in the following way:

{ path: 'somePath', component: someComponent, data: {someParaName: SomeEnum.SomeOption}}

this gives the Unhandled Rejection at: Promise error. It goes away when you remove the Routes typing as suggested by @WebStew above but then Compodoc just doesn't generate the routes part of the documentation.

A fix for now is calling valueOf() on the enum:

{ path: 'somePath', component: someComponent, data: {someParaName: SomeEnum.SomeOption.valueOf()}}

The generation throws no errors and the routes are included in the documentation.
\
\
Some extra information.
enum is imported as:

import { SomeEnum } from 'app/model';

Routes are declared as:

const APP_ROUTES: Routes = [
  { path: 'somePath', component: someComponent, data: {someParaName: SomeEnum.SomeOption.valueOf()}},
];

\
\
@vogloblinsky do you have any idea what is causing the error? Do you need more info/how can I help you pinpoint the issue?

Maybe this issue or one of the issues this was just referenced in (all of which look like the same problem to me) should be included in the routing issues project.

The problem seems to be in typing routes as Routes. Without type it works seamlessly.

Having the same issue

Compodoc v1.1.7
Angular CLI 7.2.2

Clear up "Routes" types fixes the problem, but I think it's not okay to do like that

Also having the same issue with version 1.1.8.

This is happening when i reference any route property from environment files e.g.

data: { title: environment.feature.name }

I am having this issue too

I solved this problem by using the solution @bartios posted earlier in this thread. When defining a Routes array in a routing module, reference enum values by their .valueOf() method.

So instead of:
data: { fooProperty: FooEnum.FooPermission }
Use:
data: { fooProperty: FooEnum.FooPermission.valueof() }

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem. Why locking ? Having issues with the most up-to-date context.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elvisbegovic picture elvisbegovic  路  14Comments

crh225 picture crh225  路  20Comments

moramike picture moramike  路  15Comments

nikhilknoldus picture nikhilknoldus  路  18Comments

dharsanav picture dharsanav  路  15Comments