glTF-Sample-Viewer icon indicating copy to clipboard operation
glTF-Sample-Viewer copied to clipboard

app_web error starting on Windows 10

Open ieremius opened this issue 3 years ago • 2 comments

This is likely due to my own ignorance (about node (with which I have limited experience) and maybe WebGL - so far I've just been developing OpenGL in the context of a Windows client)...if so, my appologies in advance!

I'm trying to start app_web after following the simple instructions in the README, but I get this error on the first character of some (any) shader code:

PS C:\Users\ierem\source\repos\glTF-Sample-Viewer\app_web> npm run dev

> [email protected] dev
> concurrently "rollup -c -w" "serve --listen 8000 dist"

[1]  INFO  Accepting connections at http://localhost:8000
[0] rollup v2.79.1
[0] bundles src/main.js → dist/GltfSVApp.js...
[0] copied:
[0]   index.html → dist\index.html
[0]   main.js → dist\main.js
[0]   ../assets/models/2.0 → dist\assets\models\2.0
[0]   ../assets/environments/Cannon_Exterior.hdr → dist\assets\environments\Cannon_Exterior.hdr
[0]   ../assets/environments/Colorful_Studio.hdr → dist\assets\environments\Colorful_Studio.hdr
[0]   ../assets/environments/doge2.hdr → dist\assets\environments\doge2.hdr
[0]   ../assets/environments/ennis.hdr → dist\assets\environments\ennis.hdr
[0]   ../assets/environments/field.hdr → dist\assets\environments\field.hdr
[0]   ../assets/environments/footprint_court.hdr → dist\assets\environments\footprint_court.hdr
[0]   ../assets/environments/helipad.hdr → dist\assets\environments\helipad.hdr
[0]   ../assets/environments/neutral.hdr → dist\assets\environments\neutral.hdr
[0]   ../assets/environments/papermill.hdr → dist\assets\environments\papermill.hdr
[0]   ../assets/environments/pisa.hdr → dist\assets\environments\pisa.hdr
[0]   ../assets/environments/Wide_Street.hdr → dist\assets\environments\Wide_Street.hdr
[0]   ../assets/environments/doge2.jpg → dist\assets\environments\doge2.jpg
[0]   ../assets/environments/ennis.jpg → dist\assets\environments\ennis.jpg
[0]   ../assets/environments/field.jpg → dist\assets\environments\field.jpg
[0]   ../assets/environments/footprint_court.jpg → dist\assets\environments\footprint_court.jpg
[0]   ../assets/environments/helipad.jpg → dist\assets\environments\helipad.jpg
[0]   ../assets/environments/neutral.jpg → dist\assets\environments\neutral.jpg
[0]   ../assets/environments/papermill.jpg → dist\assets\environments\papermill.jpg
[0]   ../assets/environments/pisa.jpg → dist\assets\environments\pisa.jpg
[0]   ../assets/images → dist\assets\images
[0]   ../assets/ui → dist\assets\ui
[0]   ../source/libs/libktx.js → dist\libs\libktx.js
[0]   ../source/libs/libktx.wasm → dist\libs\libktx.wasm
[0] (!) `this` has been rewritten to `undefined`
[0] https://rollupjs.org/guide/en/#error-this-is-undefined
[0] node_modules/iobuffer/lib-esm/text-encoding-polyfill.js
[0] 177:     : typeof self !== 'undefined'
[0] 178:         ? self
[0] 179:         : this);
[0]                ^
[0] 180: //# sourceMappingURL=text-encoding-polyfill.js.map
[0] [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
[0] node_modules/gltf-viewer-source/shaders/panorama_to_cubemap.frag (1:0)
[0] 1: #define MATH_PI 3.1415926535897932384626433832795
[0]    ^
[0] 2: #define MATH_INV_PI (1.0 / MATH_PI)
[0] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
[0]     at error (C:\Users\ierem\source\repos\glTF-Sample-Viewer\app_web\node_modules\rollup\dist\shared\rollup.js:198:30)
[0]     at Module.error (C:\Users\ierem\source\repos\glTF-Sample-Viewer\app_web\node_modules\rollup\dist\shared\rollup.js:12560:16)
[0]     at Module.tryParse (C:\Users\ierem\source\repos\glTF-Sample-Viewer\app_web\node_modules\rollup\dist\shared\rollup.js:12937:25)
[0]     at Module.setSource (C:\Users\ierem\source\repos\glTF-Sample-Viewer\app_web\node_modules\rollup\dist\shared\rollup.js:12842:24)
[0]     at ModuleLoader.addModuleSource (C:\Users\ierem\source\repos\glTF-Sample-Viewer\app_web\node_modules\rollup\dist\shared\rollup.js:22090:20)
[0]

Then if I browse to http://localhost:8000 the page just displays text/doesn't load models.

This is on Windows 10. npm: '9.2.0' node: '18.12.1' Browser: Chrome or Firefox (they both work for me of course when accessing https://github.khronos.org/glTF-Sample-Viewer-Release/)

Since the error says "Unexpected token (Note that you need plugins to import files that are not JavaScript)" and it's complaining about glsl, I've spent some time trying some things related to plugins and glsl and glslify without success. On the other hand, I get the impression npm install combined with the rollup-config is supposed to just work without me needing to seprately install some dependency/plugin.

Thanks in advance.

ieremius avatar Dec 19 '22 01:12 ieremius

I was able to reproduce your issue with npm version 9.2.0. npm introduced breaking changes in version 9. You can switch to the previous npm version with npm install -g [email protected] (Tested on Windows 10, npm 8.19.3, node 16.13.2)

UX3D-kanzler avatar Dec 20 '22 15:12 UX3D-kanzler

@UX3D-kanzler, your suggested workaround did the trick for me. Thank you!

ieremius avatar Jan 02 '23 17:01 ieremius