browserify/commonjs-assert

Cannot read property 'isPromise' of undefined

Borewit opened this issue · 5 comments

Issue

I got experience the following issue with assert@2.0.0

Uncaught TypeError: Cannot read property 'isPromise' of undefined
    at Object../node_modules/assert/build/assert.js (assert.js:42)

Workaround

Downgrade to assert@1.5.0

Ref

My issue: Borewit/audio-tag-analyzer#97

assert@2 depends on util@0.12.x, which has an isPromise function. maybe webpack is preferring its own version of util over the one we depend on?

Thank you for your reply @goto-bus-stop.

The issue is indeed caused by a combination of assert@2.0.0 & util@0.11.0.

node-libs-browser depends on:

  • assert@1.1.1
  • util@0.11.0
    which is causing a version conflict.

Instead of downgrading, using yarn, you may add the following to your package.json

"resolutions": {
      "**/util": "^0.12.0"
  }

Good to hear you figured out a workaround! We do require('util/') which makes browserify pick the version we depend on instead of the one browserify bundles, wonder if we can do another trick to make webpack do the same…

(FWIW, node-libs-browser is pretty much unmaintained. With webpack@5, you'll be expected to manually install shims for Node.js core modules, so they're not investing time in keeping that stuff up to date.)

wonder if we can do another trick to make webpack do the same

By explicitly requiring util WebPack takes the dependency into account and may respect the util dependency version right?

node-libs-browser is pretty much unmaintained

I know, most likely the PR will not be accepted, but I documented the solution for this problem.