You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use the version 5.2.0 of openapi-typescript, there is this error when i try to import the openApiTS function :
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/rguarinoni/Documents/findAMusician/findAMusicianBackend/node_modules/openapi-typescript/dist/index.js
require() of ES modules is not supported.
require() of /home/rguarinoni/Documents/findAMusician/findAMusicianBackend/node_modules/openapi-typescript/dist/index.js from /home/rguarinoni/Documents/findAMusician/findAMusicianBackend/api/command/generateType.ts is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/rguarinoni/Documents/findAMusician/findAMusicianBackend/node_modules/openapi-typescript/package.json.
at new NodeError (node:internal/errors:363:5)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1126:13)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (/home/rguarinoni/Documents/findAMusician/findAMusicianBackend/api/command/generateType.ts:4:1)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Module.m._compile (/home/rguarinoni/Documents/findAMusician/findAMusicianBackend/node_modules/ts-node/src/index.ts:1371:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1138:10) {
code: 'ERR_REQUIRE_ESM'
}
I found a way to fix the issue by downgrading to 4.4.0. Additionnaly, i noticed that a big difference was the presence of the dependecy kleur in the package.json which i suspect can be the cause of the issue.
The text was updated successfully, but these errors were encountered:
I’m going to close in favor of #888. If you could document your build tooling, and how you’re compiling TypeScript (e.g. what is your target in tsconfig.json? are you using ts-node? etc.), I’d love additions to the README on using the new ESM version with specific build tooling.
When I use the version
5.2.0
ofopenapi-typescript
, there is this error when i try to import theopenApiTS
function :I found a way to fix the issue by downgrading to
4.4.0
. Additionnaly, i noticed that a big difference was the presence of the dependecykleur
in thepackage.json
which i suspect can be the cause of the issue.The text was updated successfully, but these errors were encountered: