Why bluebird packages is not work in nestjs

183 views Asked by At

I'm using these following packages:

  • @nestjs/core 9.0.0
  • bluebird 3.7.2
  • @types/bluebird 3.5.38

Here is my tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false,
    "esModuleInterop": true
  }
}

When I use Bluebird.map like

            await Bluebird.map(dataAccessories, accessory => {
                const { accessory_id, quantity } = accessory
                return Accessory.update({
                    where: { id: accessory_id },
                    data: {
                        inventory: {
                            increment: quantity
                        }
                    }
                })
            }, { concurrency: 5 })

It throws error as below:

    TypeError: obj._then is not a function

      at tryConvertToPromise (node_modules/bluebird/js/release/thenables.js:19:21)
      at MappingPromiseArray._promiseFulfilled (node_modules/bluebird/js/release/map.js:81:28)
      at MappingPromiseArray.PromiseArray._iterate (node_modules/bluebird/js/release/promise_array.js:115:31)
      at MappingPromiseArray.init (node_modules/bluebird/js/release/promise_array.js:79:10)
      at MappingPromiseArray._asyncInit (node_modules/bluebird/js/release/map.js:37:10)
      at _drainQueueStep (node_modules/bluebird/js/release/async.js:97:12)
      at _drainQueue (node_modules/bluebird/js/release/async.js:86:9)
      at Async.Object.<anonymous>.Async._drainQueues (node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues (node_modules/bluebird/js/release/async.js:15:14)

How can I resolve this problem? Thanks

0

There are 0 answers