Notification texts go here Contact Us Buy Now!

getting filehandler is not a constructor when using new filehandler but does not work as static class

When attempting to export a JavaScript module, it's best practice to specify a default or named exports to facilitate proper usage.

In your case, since you're not specifying a default export, importing the module using the FileHandler variable as a constructor will result in an error because it's not a constructor function. To resolve this:

  • Option 1: Use named exports.

import * as filehandler from "../index.js";

const FileHandler = filehandler.FileHandlerStatic;

  • Option 2: Use the as keyword when importing named exports.
import { FileHandlerStatic as FileHandler } from "../index.js";

Both approaches ensure proper usage of your exported module and avoid the "filehandler is not a constructor" error when using new filehandler.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.