-
Notifications
You must be signed in to change notification settings - Fork 215
Closed
Labels
Description
Hey guys so unfortunately I think this still doesn't work. Or it's also entirely possible I'm doing something wrong but, whenever I try to import something from ts-json-schema-generator
I get this error:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/stevencummings/workspace/ternary/core-web-server/node_modules/ts-json-schema-generator/cjs/index.js from /Users/stevencummings/workspace/ternary/core-web-server/scripts/docs-gen/Oas3Generator.ts not supported.
index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/stevencummings/workspace/ternary/core-web-server/node_modules/ts-json-schema-generator/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
Sorry if this isn't the best place to discuss, lmk if I should open a new issue or what the best thing is to do.
Originally posted by @sacummings91 in #1964 (comment)