Error when building a react app
See original GitHub issueFirst of all, great work guys! I read your medium posts and had to try out the library. 👏 I’m trying to integrate 3d view and ar features in my existing react project. But I’m getting the following error:
index.js:1 SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at GLTFLoader.parse (GLTFLoader.js:213)
at Object.onLoad (GLTFLoader.js:145)
at XMLHttpRequest.<anonymous> (three.module.js:36216)
I’ve made a WebARTest component, then import and render it in App.js. This is how my code looks:
import View3D, { GLTFLoader } from '@egjs/view3d';
import React, { useRef, useEffect } from 'react';
import './viewstyles.css';
const WebARTest = () => {
const canvasElement = useRef(null);
useEffect(() => {
const view3d = new View3D(canvasElement.current);
const loader = new GLTFLoader();
loader
.load('./assets/specstand.glb')
.then((model) => {
view3d.display(model);
})
.catch((e) => {
console.error(e);
});
}, [canvasElement]);
return (
<div id="view3d-wrapper">
<canvas id="ar-canvas" ref={canvasElement}></canvas>
</div>
);
};
export default WebARTest;
I’m following the instruction listed on your tutorial page for loading a model.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Create React App not working - Stack Overflow
1. update the npm version (npm install npm@latest -g) · 2. clear the cache (npm cache clean --force) · 3. create the react...
Read more >How to fix build failures with `create-react-app` in production
The build script bootstrapped by create-react-app performs some validation of your code. When most of this validation fails, create-react-app ...
Read more >react-scripts fails to build project with Node 17 #11562 - GitHub
Describe the bug we have a CRA app, it used to build with Node 14.x very fine, today I upgrade nodejs to 17.0.0...
Read more >npx create-react-app not working? Here's the solution.
The current solution is simple — run create-react-app and target the latest version. Run creact-react-app using the latest version. npx create- ...
Read more >Error Decoder - React
We highly recommend using the development build locally when debugging your app since it tracks additional debug info and provides helpful warnings about ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@devhims I’m glad to hear that 👍 Don’t worry about filing more issues. I may be slow to respond if I’m working on other things, but I’ll check yours soon as I can 😃
@devhims Hmm, in that case I assume that file is not loaded as a static file but in the format of a HTML page. Check what it shows on the
./assets/specstand.glb
page and if it shows a HTML page, fix the config to serve static files on the assets folder. In other way, moving the 3D model to thepublic
folder will work I think.