Aurelia Frontend: Module not found: Error: Can't resolve 'async_hooks' in bluebirdjs

If you are using the @dolittle/build.aurelia package, you may encounter this error when trying to build your frontends with the latest versions of bluebird (v.3.6.0 & 3.7.0).

Console Output:

ERROR in ./node_modules/bluebird/js/release/promise.js
Module not found: Error: Can't resolve 'async_hooks' in '/ProjectPath/Web/node_modules/bluebird/js/release'
 @ ./node_modules/bluebird/js/release/promise.js 34:4-26
 @ ./node_modules/bluebird/js/release/promise.js-exposed
 @ ./node_modules/bluebird/js/release/bluebird.js
 @ ./node_modules/bluebird/js/release/bluebird.js-exposed

QuickFix

Clamp down the version of bluebird in your project’s package.json to v.3.5.5 by running this command in your Web folder:

npm install bluebird@3.5.5

or to the highest patch v3.5.x

npm install bluebird@~3.5.5

Longer Term Fix

We need to figure out why this error is occurring, and see if there’s something that can be resolved in the build-backage. I also see that Aurelia have moved away from bluebird in their official boilerplates, so perhaps this could also be something to consider.

2 Likes

Thans for this Tip @pavneet!

I tried to spin a bit on the last part you’re writing there. So I removed all Bluebird stuff from @dolittle/build.aurelia and from main.js in my app. It builds without any errors. But I don’t know how it will impact the app in function.

1 Like

Great to hear @Vidar! I think you’ve described the default behaviour in most modern browsers. They mostly support native promises: https://caniuse.com/#search=Promise

Aurelia has officially moved over to use polyfill-promise package. I think it’s mostly relevant for IE11 support, these days.

Perhaps we could move the IE support to a separate package you need to opt-in to? Ex @dolittle/client.aurelia.ie. Alternatively just document the needed steps required to add the polyfill in your project.

Hey @pavneet, I tested the updated package now, 3.3.1, with Bluebird ~3.5.5. But I still get the error. Should I try updating it and lock it up to 3.5.5 without the ~ ?

Could you check the lock files (yarn.lock or package-lock.json) to see which version it actually resolves to?

I don’t quite know what in the lock file says what it resolved, but I’m guessing that the ones at root level is what we’re looking for?

bluebird@^3.3.0, bluebird@^3.5.5:
  version "3.7.1"
  resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.1.tgz#df70e302b471d7473489acf26a93d63b53f874de"
  integrity sha512-DdmyoGCleJnkbp3nkbxTLJ18rjDsE4yCggEwKNXkeV123sPNfOCYeDoeuOY+F2FrSjO1YXcTU+dsy96KMy+gcg==

bluebird@~3.5.5:
  version "3.5.5"
  resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.5.tgz#a8d0afd73251effbbd5fe384a77d73003c17a71f"
  integrity sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==

The places where it’s a dependency, is these:

"@dolittle/build.aurelia@^3.3.1":
  dependencies:
    bluebird "~3.5.5"

bfj@^6.1.1:
  dependencies:
    bluebird "^3.5.5"

cacache@^12.0.2:
  dependencies:
    bluebird "^3.5.5"

karma@^3.1.4:
  dependencies:
    bluebird "^3.3.0"
1 Like

OK, so setting the version to ~3.5.5 doesn’t have the desired effect. Perhaps setting it to 3.5.5 explicitly will do the trick?

For reference, this is the issue on github: https://github.com/dolittle-interaction/JavaScript.Build.Aurelia/issues/23#issuecomment-544863667