vasturiano / aframe-forcegraph-component

Force-directed graph component for A-Frame
https://vasturiano.github.io/aframe-forcegraph-component/
MIT License
77 stars 31 forks source link

TypeError: accessorFn is not a function using the npm module #22

Closed christianvari closed 4 years ago

christianvari commented 4 years ago

Hello and thank you for sharing this project.

Describe the bug Using the cdn is all fine but if I use the npm module and then I use import, i got this error. I tried to add accessor-fn to my dependencies but it didn't work.

This is the stacktrace

TypeError: accessorFn is not a function using the npm module i.tick C:/Users/christian.vari/Desktop/vr_scr/node_modules/aframe-forcegraph-component/index.js:300 297 | } 298 | 299 | this.state.hoverObj = topObject; 300 | this.state.tooltipEl.setAttribute('value', topObject ? accessorFn(this.data[topObject.graphObjType + 'Label'])(topObject.data) || '' : ''); | ^ 301 | this.state.subTooltipEl.setAttribute('value', topObject ? accessorFn(this.data[topObject.graphObjType + 'Desc'])(topObject.data) || '' : ''); 302 | } 303 |

vasturiano commented 4 years ago

@christianvari thanks for reaching out.

As you can see here, accessor-fn is a dependency of this package: https://github.com/vasturiano/aframe-forcegraph-component/blob/master/package.json#L52

Have you npm installed this package fully?

christianvari commented 4 years ago

@vasturiano Thanks for the reply.

I am using it with react. I fixed the issue changing the line 7 of /aframe-forcegraph-component/index.js from "var accessorFn = require('accessor-fn');" to "import accessorFn from 'accessor-fn';"

Is there a better solution?

vasturiano commented 4 years ago

@christianvari you should ensure that your application build can read from commonJs modules, using require statements.

christianvari commented 4 years ago

ok, thank you for your time.