Nx: dep graph not generated due to errors

Created on 4 Jul 2019  路  15Comments  路  Source: nrwl/nx

Expected Behavior

It should generate the dependencies graph of my project.

Current Behavior

When I run npm run dep-graph It generates an image with all my libs and apps in a row with no connections between them.

Failure Information (for bugs)

[project root]node_modules/viz.js/viz.js:33 Invalid asm.js: Function definition doesn't match use

Steps to Reproduce

  1. npm run dep-graph

Context

Angular CLI version output

Angular CLI: 8.0.3
Node: 12.3.1
OS: darwin x64
Angular: 8.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.800.1
@angular-devkit/build-angular      0.800.6
@angular-devkit/build-ng-packagr   0.800.6
@angular-devkit/build-optimizer    0.800.6
@angular-devkit/build-webpack      0.800.6
@angular-devkit/core               8.0.1
@angular-devkit/schematics         8.0.1
@angular/cdk                       8.0.1
@angular/flex-layout               8.0.0-beta.26
@angular/material                  8.0.1
@angular/material-moment-adapter   8.0.1
@ngtools/json-schema               1.1.0
@ngtools/webpack                   8.0.6
@schematics/angular                8.0.1
@schematics/update                 0.800.3
ng-packagr                         5.3.0
rxjs                               6.5.2
typescript                         3.4.5
webpack                            4.30.0

Nx version

8.1.2

Other

I began to notice this error after importing an existing project to our monorepo. After the import several libraries and apps where created although it did not require adding any extra dependency, they were libs and apps pretty similar to the ones that were already in the monorepo.

community core bug

Most helpful comment

https://github.com/ynoval/mssone.git is a repo with he same error:
$ npm run dep-graph
..

nx dep-graph

(node:31475) V8: /home/yoel/MSS-ONE/borrar/mssone/node_modules/viz.js/viz.js:33 Invalid asm.js: Function definition doesn't match use

Angular CLI: 8.0.0
Node: 12.6.0
OS: linux x64
Angular: 8.1.2

Thanks!! Nx is a great tool

All 15 comments

@cladera could you provide a repro?

I tried (https://github.com/cladera/nx-dep-graph-issue) but I couldn't reproduce the error. I guess there is something wrong specific to my libraries and apps or with my vendor dependencies.

But I do see though is the same error message in the log:

> [email protected] dep-graph /Users/cgcladera/Desktop/dep-graph-issue
> nx dep-graph

(node:10016) V8: /Users/cgcladera/Desktop/dep-graph-issue/node_modules/viz.js/viz.js:33 Invalid asm.js: Function definition doesn't match use

@cladera we are using graphviz to generate the graph.

I might be related to https://github.com/mdaines/viz.js/issues/96.

I'm really sorry but it's hard for us to investigate without having a repro. So if you cannot create a repro, I'll have to close the issue.

@vsavkin Don't worry, I totally understand. I'll try to debug my self in our project and get back to this issue if I learn something new.

https://github.com/ynoval/mssone.git is a repo with he same error:
$ npm run dep-graph
..

nx dep-graph

(node:31475) V8: /home/yoel/MSS-ONE/borrar/mssone/node_modules/viz.js/viz.js:33 Invalid asm.js: Function definition doesn't match use

Angular CLI: 8.0.0
Node: 12.6.0
OS: linux x64
Angular: 8.1.2

Thanks!! Nx is a great tool

Same problem, @cladera @ynoval did you guys found any workaround or cause of this? Thanks!

Same problem here ((((

C:\Projects\Angular\work>nx dep-graph --verbose
(node:1232) V8: C:\Projects\Angular\work\node_modules\viz.js\viz.js:33 Invalid asm.js: Function definition doesn't match use

@mtuzinskiy No, I didn't. Actually it became a real pain. Now I don't know if the problem is with the graph generation or nx is not actually able to map my dependencies.

I ran into serious problems lately because of this problem...

@cladera Well, I have tried it out with freshly created Nx project, and it's the same. So it's NOT related to your dependencies. Could you please try it with the fresh one too, to verify? Shouldn't take much of your time :)

@mtuzinskiy I did what you suggested. I created a brand new project with one angular app and one angular library. When I run npm run dep-graph I got the mentioned error but the graph tree is rendered whereas in my project it will never render.

```
(node:1729) V8: /Users/cgcladera/Desktop/dep-graph/node_modules/viz.js/viz.js:33 Invalid asm.js: Function definition doesn't match use
````

Screen Shot 2019-09-23 at 09 11 52

@cladera Could you please re-check if you have the same version of Nx in your new and old project?

I did more digging. It looks like the issue occurs only on Node 12.

It looks like the following libraries are deprecated:

"graphviz": "^0.0.9",
"viz.js": "^1.8.1",

I think we should replace it with:
https://github.com/dagrejs/dagre/wiki

Would you like to do it folks? It's just one file in the nx repo that has to be updated. I can help you out.

@mtuzinskiy yes, I had the same version in my project and in the brand new project.

I figure out what was going on with my project and I think it is solved now.

There were two things I configured wrong:

  1. At some point we changed the npmScope property in the nx.json file. After some time debugging I realized this value is passed to the dependencies calculator so I figured it had to do with how nx creates the dep tree. When I changed the npmScope to its original value, all the projects with that scope in the tsconfig.json's paths appeared connected in the dep graph.

  2. We had libraries with different npm scopes (changed manually in tsconfig.json file). We needed to do so for libraries that we wanted to publish to npm and not all of them were under the same npm scope.
    If I use the same scope for all my libraries and apps the dep graph is generated right. In our case it's alright because the libraries we were publishing to npm were private and actually all its dependant are now part of the monorepo so we no longer need to publish them. But still it is kind of a limitation, isn't it?

We no longer use graphviz for our dep-graph so this issue should not occur as of 8.6.0.

Please file a new issue if you have issues with the new implementation for dep-graph.

Was this page helpful?
0 / 5 - 0 ratings