A
arktype3w ago
Blitz

Trying to use Arktype with nestjs module problems

I don't undestand why i'm getting problems with
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/kordian/Projects/kindora-backend/node_modules/.pnpm/arktype@2.1.20/node_modules/arktype/out/index.js from /Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js not supported.
Instead change the require of index.js in /Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js:4:19) {
code: 'ERR_REQUIRE_ESM'
}
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/kordian/Projects/kindora-backend/node_modules/.pnpm/arktype@2.1.20/node_modules/arktype/out/index.js from /Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js not supported.
Instead change the require of index.js in /Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/kordian/Projects/kindora-backend/dist/src/database/pagination.types.js:4:19) {
code: 'ERR_REQUIRE_ESM'
}
I'm using this tsconfig
{
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"isolatedModules": true,
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2023",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": false,
"strictBindCallApply": false,
"noFallthroughCasesInSwitch": false,
}
}
{
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"isolatedModules": true,
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2023",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": false,
"strictBindCallApply": false,
"noFallthroughCasesInSwitch": false,
}
}
Whenever I switch my module to esnext all the imports no longer are working
3 Replies
ssalbdivad
ssalbdivad3w ago
ArkType only supports ESM, which is supported by modern runtimes including node, even from CJS. You could try enabling "type": "module" in your package.json or just upgrading your runtime to a newer version of Node.
Blitz
BlitzOP3w ago
updating node version actually worked, why didn't i think of that thank you sorry for being a moron
ssalbdivad
ssalbdivad3w ago
you're not a moron! that stuff has plagued the ecosystem for years hopefully soon with new versions being installed that support it by default it will be less and less frequent to run into that stuff, but always happy to help however I can!

Did you find this page helpful?