pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.45k stars 290 forks source link

Running npx gltfjsx Model.gltf fails with Error: Invalid hook call. #112

Open synergyseeker opened 2 years ago

synergyseeker commented 2 years ago

When running npx gltfjsx Model.gltf against any gltf model it fails. It returns this Error.

ERROR Objects are not valid as a React child (found: Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.). If you meant to render a collection of children, use an array instead. in ink-text (created by Text) in Text in ink-box (created by Box) in Box in App in App in InternalApp

-throwOnInvalidObje (/Users/richardmattka/.npm/_npx/16b3f312213fced0/node_modu ctType les/react-reconciler/cjs/react-reconciler.development.js:45 24:15) -createChil (/Users/richardmattka/.npm/_npx/16b3f312213fced0/node_modules/reac t-reconciler/cjs/react-reconciler.development.js:4757:7) -reconcileChildren (/Users/richardmattka/.npm/_npx/16b3f312213fced0/node_modul rray es/react-reconciler/cjs/react-reconciler.development.js:5008 :25) -reconcileChildFi (/Users/richardmattka/.npm/_npx/16b3f312213fced0/node_module ers s/react-reconciler/cjs/react-reconciler.development.js:5374:1 4) -reconcileChild (/Users/richardmattka/.npm/_npx/16b3f312213fced0/node_modules/ en react-reconciler/cjs/react-reconciler.development.js:7865:28) -updateHostCompo (/Users/richardmattka/.npm/_npx/16b3f312213fced0/node_modules ent /react-reconciler/cjs/react-reconciler.development.js:8387:3)

-beginWork$ (/Users/richardmattka/.npm/_npx/16b3f312213fced0/node_modules/reac t-reconciler/cjs/react-reconciler.development.js:9969:14) -Object.invokeGuardedCa (/Users/richardmattka/.npm/npx/16b3f312213fced0/node lbackImpl modules/react-reconciler/cjs/react-reconciler.developme nt.js:11563:10) -invokeGuardedCal (/Users/richardmattka/.npm/_npx/16b3f312213fced0/node_module back s/react-reconciler/cjs/react-reconciler.development.js:11740: 31) -beginWork$ (/Users/richardmattka/.npm/_npx/16b3f312213fced0/node_modules/reac 1 t-reconciler/cjs/react-reconciler.development.js:15778:7)

jonczeck commented 2 years ago

edit: You don't get the issue at all if you install gltfjsx globally instead of using npx. I'm not sure why wiping my npx cache alone didn't solve it too.

npm i -g gltfjsx

As a temporary workaround, I've found that an older version of gltfjsx run on the same file works as expected.

npx gltfjsx@4.2.0 model.gltf

That version isn't necessarily the latest one that doesn't have this issue, but it is one that worked. I didn't try them all.

drcmda commented 2 years ago

i think i have to remove ink, it's probably not worth it just so have some colored console output.

ITBoomBKStudio commented 2 years ago

edit: You don't get the issue at all if you install gltfjsx globally instead of using npx. I'm not sure why wiping my npx cache alone didn't solve it too.

npm i -g gltfjsx

As a temporary workaround, I've found that an older version of gltfjsx run on the same file works as expected.

npx gltfjsx@4.2.0 model.gltf

That version isn't necessarily the latest one that doesn't have this issue, but it is one that worked. I didn't try them all.

Thank you. It worked for me!

jeffscottward commented 1 year ago

That didn't work for me. :-\

chillywilson commented 1 year ago

This also didn't work for me as well. After hours of trying to nvm different versions, removing and re-installing npm, nvm, node... ect I still get this error. Powershell, gitbash, cmd... I used the online converter which worked but this drove me nuts to figure out.

I finally was able to solve it. For me it was my file location, my directory had a file location with space in it and some other issue the shell didn't like. I move the file to my desktop and the conversion worked. So I would try that @jeffscottward