Instead change the require of index.js in [...] to a dynamic import() which is available in all CommonJS modules.
Additional context
Typescript + NestJs
Apparently lib only includes the compiled "dist" javascript, so when tryong to run it in an "Typescript environment" such as the development server, gives the error.
Describe the bug
The lib is giving errors on typescript when default config is used
Expected behavior
Using same code as the example:
`import { HiAnime, HiAnimeError } from "aniwatch";
const hianime = new HiAnime.Scraper();
try { const result: HiAnime.ScrapedAnimeAboutInfo = await hianime.getInfo( "steinsgate-3" ); console.log(result); } catch (err) { console.error(err instanceof HiAnimeError, err); }`
In a Typescript + NestJs environment with the next tsbuild.config
{ "compilerOptions": { "module": "CommonJS", "moduleResolution": "node", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es2020", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true, "skipLibCheck": true, "strictNullChecks": false, "noImplicitAny": false, "strictBindCallApply": false, "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false, "esModuleInterop": true, "allowSyntheticDefaultImports": true }, "include": [ "./src/**/*" ], "exclude": [ "node_modules" ] }
Actual behavior
Gives the error:
const aniwatch_1 = require("aniwatch");
Error [ERR_REQUIRE_ESM]: require() of ES Module
Instead change the require of index.js in [...] to a dynamic import() which is available in all CommonJS modules.
Additional context
Typescript + NestJs
Apparently lib only includes the compiled "dist" javascript, so when tryong to run it in an "Typescript environment" such as the development server, gives the error.