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
.