matomo-org / matomo-nodejs-tracker

A Node.js wrapper for the Matomo (Piwik) tracking HTTP API
MIT License
117 stars 41 forks source link

Import error: TypeError: Vn is not a constructor #72

Open Dominic-Marcelino opened 2 years ago

Dominic-Marcelino commented 2 years ago

Due to our build-pipeline we can't use require to include the module. Using require it would't get bundled into the final build.

If we try to use import (import * as MatomoTracker from "matomo-tracker"; ) we can bundle it correctly but it throws an error on runtime: TypeError: Vn is not a constructor

Is there anything we can do?

Thanks a lot

Findus23 commented 2 years ago

Have you tried using the beta version? https://www.npmjs.com/package/matomo-tracker

It is using typescript and assuming I published it correctly (#64), it should probably work better with imports.

Dominic-Marcelino commented 2 years ago

VsCode displays an error related to the construct signature, but except from that it seems to work! (from the first tests)

Now importing it via import MatomoTracker from "matomo-tracker";

The TS-Error in VsCode:

This expression is not constructable.
  Type 'typeof import("/Users/dominic/Code/_directus-extensions/directus-extension-application-monitoring/node_modules/matomo-tracker/index")' has no construct signatures.ts(2351)