victordibia / handtrack.js

A library for prototyping realtime hand detection (bounding box), directly in the browser.
https://victordibia.com/handtrack.js/
MIT License
2.83k stars 250 forks source link

import statement error in node.js #45

Open MiloAkerman opened 3 years ago

MiloAkerman commented 3 years ago

Hello. Whenever I install the handtrackjs package in Node.js, and run my project, I get the following error:

(node:2780) ExperimentalWarning: The ESM module loader is experimental.
/Users/me/Documents/Projects/MCH/node_modules/handtrackjs/src/index.js:11
import * as tf from '@tensorflow/tfjs';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:155:15)
    at ModuleJob.run (internal/modules/esm/module_job.js:139:37)
    at async Loader.import (internal/modules/esm/loader.js:179:24)

I think the package could use a transition to CommonJS (or maybe it's something on my end)