Matter-js: Doesn't work on nodejs

Created on 7 Dec 2017  路  5Comments  路  Source: liabru/matter-js

> require('matter-js').Engine.create()
TypeError: Cannot read property 'nodeType' of undefined
    at Object.Common.isElement (/root/server/node_modules/matter-js/build/matter.js:4449:23)
    at Object.Engine.create (/root/server/node_modules/matter-js/build/matter.js:4846:26)
    at repl:1:29
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:441:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)
> 
root@7d42879a986e:~/server# cat node_modules/matter-js/package.json | grep version
    "gulp-tag-version": "^1.3.0",
  "version": "0.14.0"
bug

All 5 comments

Ugh I thought I'd solved that! Looks it needs to handle undefined.

Maybe Common.isElement can return false; instead of return !!(obj.nodeType && obj.nodeName)?

+1

A possible workaround that worked for me:
return obj && !!(obj.nodeType && obj.nodeName);

@Smeky's workaround worked for me.

Thanks @liabru! Fix works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drachehavoc picture drachehavoc  路  4Comments

ShadewEnder picture ShadewEnder  路  3Comments

liabru picture liabru  路  3Comments

car1ot picture car1ot  路  3Comments

kunchenguid picture kunchenguid  路  3Comments