import { nanoid } from "nanoid";
export class User {
...
@prop({ required: true, default: () => nanoid() })
verificationCode: string;
...
}
Ошибка:
Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/nanoid/index.js from user.model.ts not supported.
Instead change the require of index.js in user.model.ts to a dynamic import() which is available in all CommonJS modules.
tsconfig.json
{
"compilerOptions": {
"target": "ES2016",
"module": "CommonJS",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictPropertyInitialization": false,
}
}