browserify / commonjs-assert

Node.js's require('assert') for all engines
MIT License
293 stars 57 forks source link

Cannot read property 'isPromise' of undefined #49

Closed Borewit closed 4 years ago

Borewit commented 4 years ago

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

goto-bus-stop commented 4 years ago

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?

Borewit commented 4 years ago

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:

Borewit commented 4 years ago

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

"resolutions": {
      "**/util": "^0.12.0"
  }
goto-bus-stop commented 4 years ago

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.)

Borewit commented 4 years ago

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.