azavea / loam

Javascript wrapper for GDAL in the browser
Apache License 2.0
218 stars 16 forks source link

SyntaxError: Unexpected token '<' #84

Closed AdamGoodApp closed 3 years ago

AdamGoodApp commented 3 years ago

Trying to initialize loam in a create-react application but getting error event from http://localhost:3001/static/js/loam-worker.js

SyntaxError: Unexpected token '<'
ddohler commented 3 years ago

Hey @AdamGoodApp -- this can happen if the request for loam-worker.js returns a 404. Can you double-check that you've followed the instructions for integrating with create-react-app ? If you've gone through all those steps already, can you open your browser's network inspector and find the request where the browser loads loam-worker.js and provide the Response body?

AdamGoodApp commented 3 years ago

I have tried both symlinking and copying the files into the public folders my self, they are there.

My public folder looks like:

gdal.data      gdal.js        gdal.wasm      index.html     loam-worker.js manifest.json  robots.txt

In Safari I get:

HTTP/1.1 304 Not Modified

Chrome, no response in network, just console error of:

Refused to execute script from 'http://localhost:3001/static/js/loam-worker.js' because its MIME type ('text/html') is not executable.
ddohler commented 3 years ago

Hmm, can you try initializing loam this way: loam.initialize("/")?

Also, what do you get if you use your browser to navigate directly to http://localhost:3001/static/js/loam-worker.js? What about http://localhost:3001/loam-worker.js?

AdamGoodApp commented 3 years ago

Thank you!

loam.initialize("/") worked.