Closed dvaruas closed 5 years ago
Published a backwards compatibility fix in 1.2.1. I had to manually modify the build output so there is no commit that corresponds to this version of the package. Moving forward, this will not be supported in 2.0.0.
Having this problem to. Is it not possible to create an instance of AwaitLock
? What's the alternative?
The issue is with the way the module is loaded, not the constructor. Use ESM, either natively or with tsc, Babel, SWC, etc.
I'm running into the same issue. Not sure what you mean. Everything else loads fine. Not this module. How to resolve this?
import AwaitLock from 'await-lock';
....
this.mutex = new AwaitLock();
this.mutex = new AwaitLock(); ^ TypeError: AwaitLock is not a constructor at new Model (file:///home/m/scripts/model.ts:78:16) at file:///home/m/scripts/ecosystem.ts:109:14 at ModuleJob.run (node:internal/modules/esm/module_job:198:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:385:24) at async loadESM (node:internal/process/esm_loader:88:5) at async handleMainPromise (node:internal/modules/run_main:61:12)
tsconfig.json:
"compilerOptions": {
"module": "es2022",
"moduleResolution": "node",
"lib": ["es2020"],
"target": "es2020",
"esModuleInterop": true,
It's a export default module error. It can be fixed easily with adding .default
Working example:
const AwaitLock = require('await-lock').default;
let lock = new AwaitLock();
With the new version 1.2.0 this piece of code throws the error TypeError: AwaitLock is not a constructor
This works with 1.1.3 version.