gltfjsx icon indicating copy to clipboard operation
gltfjsx copied to clipboard

Error running gltfjsx with npx

Open vegancat opened this issue 1 year ago • 9 comments

runnin npx gltfjsx <model> <options> throws error below:

gltfjsx is not recognized as an internal or external command,
operable program or batch file.

seems to be a node18 incompatibility error but not sure.

it's happening after new changes were pushed recently. yesterday it was working without any problem

Node version: 18.6.0 OS: Win11

vegancat avatar May 29 '23 20:05 vegancat

hm, doesn't seem related to node 18

~/Downloads  main ✔                                                                       125d20h  ⍉
▶ nvm use node
Now using node v18.6.0 (npm v8.13.2)

~/Downloads  main ✔                                                                        125d20h  
▶ npx gltfjsx kitchen.glb --transform --simplify --keepmeshes --resolution=2048        
Need to install the following packages:
  [email protected]
Ok to proceed? (y) y
instance: No meshes with ≥5 parent nodes were found.
prune: No unused properties found.
prune: Removed types... Accessor (3)
prune: No unused properties found.
prune: Removed types... Accessor (8)
prune: No unused properties found.
group walls removed (empty)
group lamp removed (empty)
group charis removed (empty)
group plant removed (empty)
group cuttingboard removed (empty)
group Scene removed (empty)

drcmda avatar May 30 '23 08:05 drcmda

Wierd then it has to be something on my side!

vegancat avatar May 30 '23 17:05 vegancat

I seem to have problem with npx! I tried npm exec gltfjsx <model> <options> and I got error below:

npm exec gltfjsx@latest .\RockLarge3.glb -T
node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'sharp' imported from <some system path ;)>\AppData\Local\npm-cache\_npx\fbe31d99a7fa405b\node_modules\gltfjsx\src\utils\transform.js
    at new NodeError (node:internal/errors:399:5)
    at packageResolve (node:internal/modules/esm/resolve:889:9)
    at moduleResolve (node:internal/modules/esm/resolve:938:20)
    at defaultResolve (node:internal/modules/esm/resolve:1153:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.16.0

I know what sharp is but, these kinds of errors mean some directory is miss-located in the npm config and it's unable to resolve packages.

Maybe I need to find the local registry for downloaded packages and manually delete the package.

vegancat avatar May 30 '23 18:05 vegancat

For anyone facing the same issue:

seems like sharp is being used in the package but somehow is not included in dependencies.

1- I opened the _npx cache with the path in error from message above: <some system path ;)>\AppData\Local\npm-cache\_npx\fbe31d99a7fa405b

2- installed the missing sharp package (npm install didn't work so I had to be more specific):

npm install --arch=x64 --platform=win32 sharp

3- when using don't forget the @latest tag!:

npx gltfjsx@latest <model> <options>

vegancat avatar May 30 '23 18:05 vegancat

i got a similar error. gltf

marcel-codett avatar Jun 05 '23 11:06 marcel-codett

https://github.com/pmndrs/gltfjsx/issues/207#issuecomment-1605890811

1kaiser avatar Jun 25 '23 06:06 1kaiser

This still happens with Node v20.8.1 and npx.

> node -v
v20.8.1
> npx gltfjsx model.glb -t -T -S
model.glb does not exist.

verekia avatar Oct 15 '23 05:10 verekia

this works ✅🥳👍in colab code

!npm install -g n 
!n 20.8.1

!npm i gltfjsx
!wget https://cdn-luma.com/71fb8d424f400eaa324e6f9d4bf6f2af74cefb319d057afb277cc46c838ed940/Yttgh_textured_mesh_glb.glb -O a.glb
output = f'/content/a.glb'
!npx gltfjsx {output} -t -T -S

outputs

prune: No unused properties found.
prune: Removed types... Accessor (356)
instance: No meshes with ≥5 parent nodes were found.
prune: No unused properties found.
prune: No unused properties found.
prune: No unused properties found.
prune: No unused properties found.
prune: No unused properties found.
prune: No unused properties found.
/*
Auto-generated by: https://github.com/pmndrs/gltfjsx
Command: npx [email protected] /content/a.glb -t -T -S 
Files: /content/a.glb [68.23MB] > a-transformed.glb [20.4MB] (70%)
*/

1kaiser avatar Oct 16 '23 12:10 1kaiser

I am talking about not installing gltfjsx but using it directly with npx gltfjsx, which is great for 1-shot CLI tools that you don't want to have in your dependencies or in your node_modules. Can you try again without npm i gltfjsx please?

Maybe the path used by gltfjsx is relative to the binary executable location, in which case it would be in some system folder rather than the project folder.

verekia avatar Oct 16 '23 13:10 verekia