admin管理员组文章数量:1433481
I'm implementing face detection using MediaPipe in a React/TypeScript application with Vite. While the code works perfectly in development mode (npm run dev), I'm getting a constructor error when building and serving the production build (npm run build).
Uncaught TypeError: face_detection.FaceDetection is not a constructor
at main-CLsce9aG.js:31922:48179
at Qj (main-CLsce9aG.js:38:27193)
at Hk (main-CLsce9aG.js:38:47511)
at main-CLsce9aG.js:38:45609
at X_ (main-CLsce9aG.js:23:1729)
at MessagePort.p2 (main-CLsce9aG.js:23:2141)
Here is my code:
import * as FaceDetection from '@mediapipe/face_detection';
export const useFaceDetection= ( options: FaceDetectionOptions = {}): UseFaceDetectionReturn => {
useEffect(() => {
const faceDetection = new FaceDetection.FaceDetection({
locateFile: (file) => {
return `/@mediapipe/[email protected]/${file}`;
}
});
....
...Rest
}
Question
1.Why is the FaceDetection constructor not available in the production build? 2.How can I properly initialize MediaPipe Face Detection in a Vite/React production build?
Any help would be greatly appreciated!
本文标签:
版权声明:本文标题:reactjs - TypeError: face_detection.FaceDetection is not a constructor in ReactVite Production Build - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745583649a2664768.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论