Uncaught TypeError: Cannot read properties of null (reading 'je')
Closed this issue · 5 comments
I installed the latest version of this package with npm install
, and then tried to use the node REPL to lay out a simple network.
However, this failed with the error Uncaught TypeError: Cannot read properties of null (reading 'je')
.
$ node
Welcome to Node.js v16.13.0.
Type ".help" for more information.
> const cytoscape = require('cytoscape')
undefined
> const elk = require('cytoscape-elk')
undefined
>
>
> const nodes = [
... {"id": "Alice"},
... {"id": "Bob"},
... {"id": "Carol"}
... ];
undefined
>
> const links = [
... {"source": "Alice", "target": "Bob"}, // Alice → Bob
... {"source": "Bob", "target": "Carol"} // Bob → Carol
... ];
undefined
>
> const elements = [
... ...nodes.map(n => ({data: n})),
... ...links.map(n => ({data: n}))
... ];
undefined
>
> cytoscape.use(elk);
[Function: cytoscape] {
use: [Function (anonymous)],
warnings: [Function (anonymous)],
version: '3.20.0',
Stylesheet: [Function: Stylesheet],
stylesheet: [Function: Stylesheet]
}
>
> let cy = cytoscape({ elements });
undefined
> cy.layout({name: 'elk', animate: false}).run();
<ref *1> Layout {
options: {
nodeDimensionsIncludeLabels: false,
fit: true,
padding: 20,
animate: false,
animateFilter: [Function: animateFilter],
animationDuration: 500,
animationEasing: undefined,
transform: [Function: transform],
ready: undefined,
stop: undefined,
elk: { aspectRatio: 1, algorithm: undefined },
priority: [Function: priority],
name: 'elk',
cy: Core { _private: [Object] },
eles: Array {
'0': [Array],
'1': [Array],
'2': [Array],
'3': [Array],
'4': [Array],
length: 5,
_private: [Object]
}
},
_private: {
cy: Core { _private: [Object] },
listeners: [],
emitter: Emitter {
qualifierCompare: [Function: qualifierCompare],
eventMatches: [Function: eventMatches],
addEventFields: [Function: addEventFields],
callbackContext: [Function: callbackContext],
beforeEmit: [Function: beforeEmit],
afterEmit: [Function: afterEmit],
bubble: [Function: bubble],
parent: [Function: parent],
context: [Circular *1],
listeners: [],
emitting: 0
}
}
}
> Uncaught TypeError: Cannot read properties of null (reading 'je')
at Jqd (/home/jsb/code/grammar-of-networks/node_modules/elkjs/lib/elk-worker.min.js:5706:225)
at Iqd (/home/jsb/code/grammar-of-networks/node_modules/elkjs/lib/elk-worker.min.js:5685:188)
at h.dispatch (/home/jsb/code/grammar-of-networks/node_modules/elkjs/lib/elk-worker.min.js:5984:473)
at h.saveDispatch (/home/jsb/code/grammar-of-networks/node_modules/elkjs/lib/elk-worker.min.js:5984:603)
>
Showing just the code:
const cytoscape = require('cytoscape')
const elk = require('cytoscape-elk')
const nodes = [
{"id": "Alice"},
{"id": "Bob"},
{"id": "Carol"}
];
const links = [
{"source": "Alice", "target": "Bob"}, // Alice → Bob
{"source": "Bob", "target": "Carol"} // Bob → Carol
];
const elements = [
...nodes.map(n => ({data: n})),
...links.map(n => ({data: n}))
];
cytoscape.use(elk);
let cy = cytoscape({ elements });
cy.layout({name: 'elk', animate: false}).run();
I have also tried to use the library with import
, but encountered the same error.
I think this is a duplicate of #3, which was marked as stale and closed without resolution.
See also:
This issue has been automatically marked as stale, because it has not had activity within the past 14 days. It will be closed if no further activity occurs within the next 7 days. If a feature request is important to you, please consider making a pull request. Thank you for your contributions.
same issue, any ideas to fixed it ? already use web-worker, but still got the Error.
same error, any news?
"algorithm" should be without "elk."-prefix, the rest should have the prefix.
example:
var elk_options = {
name: 'elk',
elk: {
'algorithm': 'layered',
'elk.direction': 'RIGHT'
}
}
cy.layout(elk_options).run();