Using obfuscated packages: Uncaught (in promise) TypeError: {......} is not a constructor
See original GitHub issueDescribe the bug
I’m using vanilla ts project with a very basic structure here
I’ve imported the https://www.npmjs.com/package/@mediapipe/selfie_segmentation library like:
import { SelfieSegmentation } from '@mediapipe/selfie_segmentation';
When I’m in devepment mode, everything seems to work as intended but after build, I get this error:
Uncaught (in promise) TypeError: e.SelfieSegmentation is not a constructor
I’m using chrome
Note:
Everything works fine in development mode by running npm run dev
System Info
System:
OS: Windows 10 10.0.22000
CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
Memory: 22.39 GB / 31.91 GB
Binaries:
Node: 16.1.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
npm: 7.10.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
vite: ^2.4.4 => 2.5.0
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:12 (3 by maintainers)
Top Results From Across the Web
TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >Unexpected "Uncaught TypeError: XXX is not a constructor ...
Use -case: I've used this in a situation where I've created a library which exported different types of an editor (while the underlying...
Read more >TypeError when attempting to create MediaPipeHands detector
Hi, I'm sure I'm missing something simple, but the documentation here implies that I should be able to run the MediaPipeHands model in-browser...
Read more >$.fn.dataTable.Editor is not a constructor — DataTables forums
I want to use drop down list to select the Status option and hold the selected option ... jquery-3.2.1.min.js:2 Uncaught TypeError: $.fn.
Read more >wtfjs - npm
There are no other projects in the npm registry using wtfjs. ... Arrow functions can not be a constructor; arguments and arrow functions;...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Also have this issue, actually using Vite and React, but same issue.
Unhandled Exception +0ms TypeError: Dm.FaceDetection is not a constructor
putting this here to also help others when googling.
The source code of
@mediapipe/selfie_segmentation
package is obfuscated (and seems to be a CommonJS module).Rollup CommonJS plugin can’t work with obfuscated packages because it relies on static analysis to determine its exports.
I don’t know if it’s possible to fix this incompatibility. If not, maybe we need to document it somewhere.