TypeError: redlock_1.default is not a constructor
See original GitHub issuets code:
import Client from 'ioredis';
import Redlock from 'redlock';
const redisA = new Client({ host: 'ubuntu' });
const redlock = new Redlock(
// You should have one client for each independent redis node
// or cluster.
[redisA],
{
driftFactor: 0.01, // multiplied by lock ttl to determine drift time
retryCount: 10,
retryDelay: 200, // time in ms
retryJitter: 200, // time in ms
},
);
error:
const redlock = new Redlock(
^
TypeError: redlock_1.default is not a constructor
at Object.<anonymous> (c:\Users\GO_DIE\Desktop\nest-study\test\1.ts:6:17)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Module.m._compile (C:\Users\GO_DIE\AppData\Roaming\nvm\v14.4.0\node_modules\ts-node\src\index.ts:1056:23)
at Module._extensions…js (internal/modules/cjs/loader.js:1220:10)
at Object.require.extensions.<computed> [as .ts] (C:\Users\GO_DIE\AppData\Roaming\nvm\v14.4.0\node_modules\ts-node\src\index.ts:1059:12)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at main (C:\Users\GO_DIE\AppData\Roaming\nvm\v14.4.0\node_modules\ts-node\src\bin.ts:198:14)
at Object.<anonymous> (C:\Users\GO_DIE\AppData\Roaming\nvm\v14.4.0\node_modules\ts-node\src\bin.ts:288:3)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Related StackOverflow Question
Hy @YuriyTigiev,
I think your issue is a simple one 😄
Per the Use in CommonJS Projects section of the README:
Updating to your import statement to the above should fix your issue!
I just published
v5.0.0-beta.1which now publishes both ESM and CJS versions.