pmndrs / gltfjsx

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

CLI.js shows 'read-pkg-up' error [ERR_MODULE_NOT_FOUND] #219

Closed kartik1601 closed 10 months ago

kartik1601 commented 10 months ago

This error happens when I try to run the npx command to convert the gltf file into jsx. My current node version is v20.5.1 and npm version is 9.8.1. I have also installed gltfjsx package to my node modules.

image

Enloch commented 10 months ago

I got the same error as OP. It showed out of the blue as last week I was doing conversions fine. Edit: Also same Node version and npm as OP. I also tested it on 3 projects I have around and same result. Code_aw4QvR8xYe

kartik1601 commented 10 months ago

It's because the package.json file is missing the 'read-pkg-up' attribute. Please fix that @bjornstar @Enloch @fortinmike @ggozad

Alexp120 commented 10 months ago

same here, is there a way I can manually fix the dependency error or switch to an earlier version? thought it was just because I'm a noob and did something wrong.

nathaponb commented 10 months ago

Switch to node 16 (16.20.2) install gltfjsx globally npm install -g gltfjsx gltfjsx ./model.gltf -t

TymonZ commented 10 months ago

I have the same issue

kartik1601 commented 10 months ago

@nathaponb I've already tried this, it throws the same error. I've used node v16, v18 and v20, it doesn't work on any. Even after changing some packages.

MatiasMontoto commented 10 months ago

Have you tried running npm install read-pkg-up in your node_modules parent directory (srdtu-revamp for you)? I had the same issue, and I solved it that way.

nathaponb commented 10 months ago

have you tried running the standalone gltfjsx cli without npx ?

CarlosHenriqueMkt commented 10 months ago

I mixed @nathaponb + @MatiasMontoto and #201 (comment) to solve. The result is:

"dependencies": { "gltfjsx": "^6.2.11", "read-pkg-up": "^10.0.0", "sharp": "^0.32.5",

I didn't have success using NPM, so I used Yarn and worked :)

Alexp120 commented 10 months ago

my solution that worked for node v18.17.0 :

npm install read-pkg-up

that's it it works perfectly now.

HarshDubey1011 commented 10 months ago

For me I have tried all the above methods nothing worked.

So I cloned the repository locally and run the same command(npx gltfjsx modelname.glb) from the gltfjsx directory and it works. I successfully generated the modelname.jsx file.

emilie-coder commented 10 months ago

I got it to work with npm install read-pkg-up

kingkwongsta commented 10 months ago

I mixed @nathaponb + @MatiasMontoto and #201 (comment) to solve. The result is:

"dependencies": { "gltfjsx": "^6.2.11", "read-pkg-up": "^10.0.0", "sharp": "^0.32.5",

I didn't have success using NPM, so I used Yarn and worked :)

Amazing! I have been stuck on this forever and it worked, thank you

I used npm to install those three packages. Also currently on node v19.6.1

npm i gltfjsx read-pkg-up sharp

stphn commented 10 months ago

I used npm to install those three packages. Also currently on node v19.6.1

npm i gltfjsx read-pkg-up sharp

That also did the trick for me using pnpm on node: v18.16.0

Thank you

johnvnel commented 10 months ago

It did install, but I have this severity warning:

`S Command Injection - https://github.com/advisories/GHSA-926x-m6m5-3mmp No fix available node_modules/push-dir

1 high severity vulnerability

Some issues need review, and may require choosing a different dependency.`

is that fine?

resetmerlin commented 10 months ago

yeap it also worked on me.

npm i gltfjsx read-pkg-up sharp

works pretty fine(react vite environment). But the question is why it works?