-
-
Notifications
You must be signed in to change notification settings - Fork 153
Can't require('@vladmandic/face-api')
and can't import
#6
Comments
Can you describe your environment? Are you using FaceAPI from NodeJS or is this a Browser bundler? |
I'm using it from NodeJS as part of an electron application. |
To be clearer: The code that extracts face descriptors operates on the backend of the electron application - ie: on the main process, so in NodeJS-land. |
I tried this:
And get this error:
|
Could be related to: standard-things/esm#868 |
yeah, bingo. This fixed it:
|
Yup, you were on the right track, need to figure out how to best package it so it works out-of-the-box. Issue is that original Face-API was published as UMD format bundle - it works out-of-the-box, but it's "ugly* and doesn't support tree shaking (meaning bundlers cannot just import what they need, you always end up with entire bundle that bloats the project). I'm using ESM format which is great for Browser, but NodeJS hates it - and the hack you've mentioned above makes NodeJS work with ESM format. I've added CJS format for Node (preferred one), just need to make sure correct one is imported by default for each case. |
I'd like to keep this issue open until it works out-of-the-box. |
new version 0.8.1 is published and it should solve your issue (docs on how to use faceapi are updated). |
I switched to using this repo from face-api.js, but there are differences not noted in your README.
In particular this one:
Can't
require('@vladmandic/face-api')
and can't import either:[1] /Users/me/app/electron/face-extraction.js:1
[1] import * as faceapi from '@vladmandic/face-api';
[1] ^^^^^^
[1]
[1] SyntaxError: Cannot use import statement outside a module
I used to:
But I cannot:
Error when require-ing:
Version: "@vladmandic/face-api": "^0.7.4"
NodeJS Version: 12.16.3
The text was updated successfully, but these errors were encountered: