mediapipe: undefined is not a constructor
i use npm install @mediapipe/face_detection
and import
import { FaceDetection } from '@mediapipe/face_detection'
and
import { FaceDetection } from ‘@mediapipe/face_detection/face_detection’;
and do
let faceDetection = new FaceDetection();
but it tells me undefined is not a constructor (evaluating 'new _face_detection.FaceDetection()')
would you help me? or give some example for implementing it?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 19
I also get the same issues with Pose. Have changed my initialization to
but I get the same
undefined is not a constructor
.I don’t see any examples of importing from the npm-installed libraries anywhere… not sure if I’m doing this right?
Hi! Can you try using “@mediapipe/face_detection”: “^0.3” in your dependencies? The package.json I was using was in shambles. Also, to save you time, if you didn’t already see this, you’ll need to change locateFile to grab the files from your npm_modules. Something like:
It’s great that the types are included in the package, but it required a lot of troubleshooting and a weird workaround to get them to actually work. The window props are perfectly functional, but if I try to import the equivalent values, I get errors like “undefined is not a function” or “Holistic is not a constructor” even though the types say it should be fine. The workaround is to grab the functional window props and reassign the types manually.
I am getting the same issue with the pose, has anyone found any solution for it?
I experienced the same thing where it works fine in Vite’s dev server but not after building for both hands and camera_utils. Using this as a workaround:
Might have something to do with the package.json referencing
"main": "hands.js"
which contains no actual exports statements.index.d.ts
seems to have the exports but I’m not familiar with how that works.And, unrelated to this issue, I’d prefer if the library somehow made these files available and remove the dependance on a CDN, but maybe that violates the license?
import { FaceDetection } from '@mediapipe/face_detection';
let faceDetection = new FaceDetection();
i also try
import { FaceDetection } from '@mediapipe/face_detection/face_detection';
as they did in thisis there anything wrong?