question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using obfuscated packages: Uncaught (in promise) TypeError: {......} is not a constructor

See original GitHub issue

Describe 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
timothyluicommented, Nov 27, 2021

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.

3reactions
sodateacommented, Aug 22, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found