kepler.gl icon indicating copy to clipboard operation
kepler.gl copied to clipboard

Module Parse Error in WorkerJob Class: Unexpected Token in @loaders.gl/worker-utils

Open DanielLanghann opened this issue 1 year ago • 12 comments

Describe the bug When i run yarn start i got among others this error:

ERROR in ./node_modules/@loaders.gl/worker-utils/dist/lib/worker-farm/worker-job.js 9:8
Module parse failed: Unexpected token (9:8)
File was processed with these loaders:
 * ../../node_modules/source-map-loader/dist/cjs.js
 * ../../node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
|  */
| export default class WorkerJob {
>     name;
|     workerThread;
|     isRunning = true;
 @ ./node_modules/@loaders.gl/worker-utils/dist/index.js 9:0-71 9:0-71
 @ ./node_modules/@loaders.gl/arrow/dist/triangulate-on-worker.js
 @ ./node_modules/@loaders.gl/arrow/dist/index.js
 @ ./src/actions.js
 @ ./src/app.js
 @ ./src/main.js
「wdm」: Failed to compile.

I attached the entire list of errors:

stack_trace_kepler.txt

To Reproduce Steps to reproduce the behavior:

I work on MacOS (14.4.1). and use Node: v18.18.2 (I also tried newer versions)

  1. I fork the repository (and did no changes).
  2. Run: yarn global add puppeteer
  3. Run: yarn bootstrap
  4. Run: export MapboxAccessToken=<insert_my_token>
  5. Run: yarn start Now i got the attached Error Trace.

Additional context Can anyone give me a hint on how to get Kepler running locally? I tried working through the errors one by one, but no matter what I did, I kept having compatibility issues and was unable (for the past two days) to run the app. We also tried running the steps on an Ubuntu machine and launching the app in Docker. Also tried newer Versions of Node. Thank you in advance for your feedback. WR Daniel

DanielLanghann avatar Jul 23 '24 10:07 DanielLanghann

@igorDykhta Could it be yarn version issue?

ibgreen avatar Jul 23 '24 15:07 ibgreen

I'll check. I have a different issue on my side, but related to loaders.gl as well. The fork works with the same yarn version.

@ibgreen i see that there is a special rule added by @lixun910 for @probe.gl in kepler.gl-jupyter

// for compiling @probe.gl, website build started to fail (March, 2024)
  {
    test: /\.(js|ts)$/,
    loader: 'babel-loader',
    include: [
      /node_modules\/@probe.gl/,
      /node_modules\/@loaders.gl/,
      /node_modules\/@math.gl/
    ]
  }

igorDykhta avatar Jul 23 '24 16:07 igorDykhta

Thanks, Igor! I remember I added this one for kepler-jupyter build, and it should not impact kepler build? Screenshot 2024-07-23 at 9 23 52 AM

lixun910 avatar Jul 23 '24 16:07 lixun910

@DanielLanghann Could you try running igr/fix-yarn-start branch? I can't reproduce the exact error, but maybe the fix is similar to probe.gl fix.

igorDykhta avatar Jul 23 '24 19:07 igorDykhta

@igorDykhta Could it be yarn version issue?

I'm using yarn 1.22.19 on my machine.

DanielLanghann avatar Jul 25 '24 07:07 DanielLanghann

@DanielLanghann Could you try running igr/fix-yarn-start branch? I can't reproduce the exact error, but maybe the fix is similar to probe.gl fix.

@igorDykhta First, thank you for your help! I cloned the repository to have a fresh start, switched to branch igr/fix-yarn-startand run yarn global add puppeteer, yarn bootstrap, export MapboxAccessToken=<my_token> and yarn start. The last success message in the build process is success Saved lockfile. After a few warnings (almost) related to @loaders.gl I got many errors also related to @loaders.gl. Most errors are "Module parse failed: Unexpected token" errors. I'm not a Java Script Pro, but for me it seems that the current build setup is not able to parse or transpile correctly or handling the syntax of used java script features.

DanielLanghann avatar Jul 25 '24 10:07 DanielLanghann

@DanielLanghann Could you try running igr/fix-yarn-start branch? I can't reproduce the exact error, but maybe the fix is similar to probe.gl fix.

@igorDykhta First, thank you for your help! I cloned the repository to have a fresh start, switched to branch igr/fix-yarn-startand run yarn global add puppeteer, yarn bootstrap, export MapboxAccessToken=<my_token> and yarn start. The last success message in the build process is success Saved lockfile. After a few warnings (almost) related to @loaders.gl I got many errors also related to @loaders.gl. Most errors are "Module parse failed: Unexpected token" errors. I'm not a Java Script Pro, but for me it seems that the current build setup is not able to parse or transpile correctly or handling the syntax of used java script features.

Same here

pablos1rvent avatar Jul 26 '24 19:07 pablos1rvent

Hi, i've also tried to get this repo running locally somehow but always failed so far.

I've checked out igr/fix-yarn-start then yarn dlx puppeteer and yarn bootstrap which results in

➤ YN0000: ┌ Link step
➤ YN0007: │ gl@npm:6.0.2 must be built because it never has been before or the last one failed
➤ YN0009: │ gl@npm:6.0.2 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-3da27c8d/build.log)
# This file contains the result of Yarn building a package (gl@npm:6.0.2)
# Script name: install

prebuild-install warn install No prebuilt binaries found (target=20.12.0 runtime=node arch=x64 libc= platform=linux)
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/wsl2development/others/kepler.gl/node_modules/gl/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/wsl2development/others/kepler.gl/node_modules/gl/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/wsl2development/others/kepler.gl/node_modules/gl/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.cache/node-gyp/20.12.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/20.12.0',
gyp info spawn args   '-Dnode_gyp_dir=/wsl2development/others/kepler.gl/node_modules/gl/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/20.12.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/wsl2development/others/kepler.gl/node_modules/gl',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
Package xi was not found in the pkg-config search path.
Perhaps you should add the directory containing `xi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xi' found
gyp: Call to 'pkg-config --libs-only-L --libs-only-other x11 xi xext' returned exit status 1 while in angle/src/angle.gyp. while loading dependencies of binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/wsl2development/others/kepler.gl/node_modules/gl/node_modules/node-gyp/lib/configure.js:325:16)
gyp ERR! stack     at ChildProcess.emit (node:events:518:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Linux 5.15.153.1-microsoft-standard-WSL2
gyp ERR! command "/root/.nvm/versions/node/v20.12.0/bin/node" "/wsl2development/others/kepler.gl/node_modules/gl/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /wsl2development/others/kepler.gl/node_modules/gl
gyp ERR! node -v v20.12.0
gyp ERR! node-gyp -v v9.4.1
gyp ERR! not ok 

I'am using stable yarn (4.3.1) by default but also tried with yarn 3.8.3 and 1.22.22 (yarn classic) with the same result.

Devidian avatar Jul 30 '24 09:07 Devidian

@Devidian, this looks like a separate issue.

@DanielLanghann I have a fix. But I need to polish it a bit. Wll public PR soon.

mars-dlx avatar Sep 05 '24 14:09 mars-dlx

I am willing to take a look if there are loaders.gl specific issues. However @heshan0131 is in the process of modernizing the entire kepler build system so let's make sure we frame any bugs against the latest setups.

ibgreen avatar Sep 05 '24 14:09 ibgreen

@Devidian I could reproduce it in WSL.

You need to install missed GL dependencies https://github.com/stackgl/headless-gl?tab=readme-ov-file#system-dependencies

mars-dlx avatar Sep 07 '24 08:09 mars-dlx

@mars-dlx I tried your "fix-webpack-builds" branch directly and at least for the demo-app which I had been trying to run so far (with the errors like @DanielLanghann was seeing) - it worked wonderfully. Thanks! :)

alcy avatar Sep 09 '24 11:09 alcy

demo-app is upgraded to esbuild in latest alpha release.

The following commands

clone...
yarn install;
yarn bootstrap;
yarn start;

launch demo-app as expected.

igorDykhta avatar Dec 05 '24 00:12 igorDykhta