Registry /
database / nestjs-redlock-universal
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
RedlockModule
✓ import { RedlockModule } from 'nestjs-redlock-universal';
✗ const { RedlockModule } = require('nestjs-redlock-universal');
Package is ESM-only, CommonJS require will fail.
Redlock decorator
✓ import { Redlock } from 'nestjs-redlock-universal';
Named export for the method decorator.
RedlockService
✓ import { RedlockService } from 'nestjs-redlock-universal';
✗ import { RedlockService } from 'redlock-universal';
RedlockService is a NestJS-specific wrapper, not from the underlying redlock-universal package.
NodeRedisAdapter
✓ import { NodeRedisAdapter } from 'nestjs-redlock-universal';
✗ import { NodeRedisAdapter } from 'redlock-universal';
Adapters are re-exported from nestjs-redlock-universal for convenience; they are defined in redlock-universal but you should import from here.
IoredisAdapter
✓ import { IoredisAdapter } from 'nestjs-redlock-universal';
Adapter for ioredis client.
ValkeyGlideAdapter
✓ import { ValkeyGlideAdapter } from 'nestjs-redlock-universal';
✗ import { ValkeyGlideAdapter } from '@valkey/valkey-glide';
Adapter re-exported from nestjs-redlock-universal, not directly from valkey-glide.
Full setup: import modules, create Redis clients, configure RedlockModule, and use @Redlock decorator to protect a method.
import { Module } from '@nestjs/common';
import { RedlockModule, Redlock, NodeRedisAdapter } from 'nestjs-redlock-universal';
import { createClient } from 'redis';
const redis1 = createClient({ url: process.env.REDIS_URL1 ?? 'redis://localhost:6379' });
const redis2 = createClient({ url: process.env.REDIS_URL2 ?? 'redis://localhost:6380' });
const redis3 = createClient({ url: process.env.REDIS_URL3 ?? 'redis://localhost:6381' });
await Promise.all([redis1.connect(), redis2.connect(), redis3.connect()]);
@Module({
imports: [
RedlockModule.forRoot({
nodes: [
new NodeRedisAdapter(redis1),
new NodeRedisAdapter(redis2),
new NodeRedisAdapter(redis3),
],
defaultTtl: 30000,
}),
],
})
export class AppModule {}
@Injectable()
export class PaymentService {
@Redlock({ key: 'payment:processing' })
async processPayment(orderId: string): Promise<void> {
// Protected by distributed lock
}
}
Errors
Common errors & fixes
Error: The module 'nestjs-redlock-universal' does not have a default export.
Using default import instead of named imports.
fixUse named imports: import { RedlockModule } from 'nestjs-redlock-universal'; ERR_REQUIRE_ESM: require() of ES Module not supported.
Package is ESM-only and cannot be loaded with require().
fixUse import syntax or set type: 'module' in your package.json.
TypeError: Cannot read properties of undefined (reading 'using')
RedlockService not injected due to missing module import.
fixEnsure RedlockModule is imported in the root or feature module.
RedlockError: Lock not acquired
Lock key already held by another process or client disconnected.
fixCheck Redis connections and ensure all clients point to the same instance cluster.
Error: Reflect.defineMetadata is not a function
reflect-metadata polyfill not imported.
fixInstall and import reflect-metadata at the top of your app entry: import 'reflect-metadata';
Audit
Dependencies
@nestjs/commonrequiredCore NestJS decorators and module APIs
@nestjs/corerequiredNestJS dependency injection and lifecycle hooks
redlock-universalrequiredUnderlying distributed lock implementation (Redlock algorithm)
reflect-metadatarequiredRequired by NestJS for decorator metadata reflection
redisoptionalNode.js Redis client (one of three optional clients)
ioredisoptionalAlternative Redis client with better support for clusters/sentinel
@valkey/valkey-glideoptionalOfficial Valkey GLIDE client