calvinmetcalf / crypto-pouch

plugin for encrypted pouchdb/couchdb databases
MIT License
243 stars 43 forks source link

Not working with Angular 6.1.8 - Uncaught TypeError: Cannot read property 'prototype' of undefined at inherits (/node_modules/hash-base/index.js:16) #67

Closed kgathuru closed 3 years ago

kgathuru commented 6 years ago

I've managed to get pouch and the other pouch plugins working in angular 6.1.8, but I have had to disable crypto pouch.

Uncaught TypeError: Cannot read property 'prototype' of undefined
    at inherits (inherits_browser.js:5)
    at Object../node_modules/hash-base/index.js (index.js:16)
    at __webpack_require__ (bootstrap:83)
    at Object../node_modules/ripemd160/index.js (index.js:3)
    at __webpack_require__ (bootstrap:83)
    at Object../node_modules/pbkdf2/lib/sync-browser.js (sync-browser.js:2)
    at __webpack_require__ (bootstrap:83)
    at Object../node_modules/pbkdf2/lib/async.js (async.js:3)
    at __webpack_require__ (bootstrap:83)
    at Object../node_modules/pbkdf2/browser.js (browser.js:1)

I wonder if the problem could related to the issue mentioned below - removed shims for global and process: https://github.com/angular/angular-cli/issues/9827#issuecomment-369578814

The solution that helped with the other pouch libraries and plugins was to add the following to polyfills:

(window as any).global = window;
(window as any).process = window;
(window as any).process.browser = true;
(window as any).process.version = '';
(window as any).process.versions = {node: false};
declare var global: any;
global.Buffer = global.Buffer || require('buffer').Buffer;
fpassa commented 5 years ago

Same issue here when attempting to run mysqljs in Ionic4.

It produces de the following error: ERROR TypeError: Cannot read property 'prototype' of undefined at Object.inherits (inherits_browser.js:5) at Object../node_modules/mysql/lib/protocol/Protocol.js (Protocol.js:9) at __webpack_require__ (bootstrap:83) at Object../node_modules/mysql/lib/Connection.js (Connection.js:6) at __webpack_require__ (bootstrap:83) at loadClass (index.js:133) at createConnection (index.js:10) at Tab2Page.push../src/app/tab2/tab2.page.ts.Tab2Page.connectDatabase (tab2.page.ts:136) at Object.eval [as handleEvent] (Tab2Page.ngfactory.js:1855) at Object.handleEvent (core.js:23107)

garbados commented 3 years ago

Howdy folks! We've just published 4.0 which changes a number of things. Could you try again with this new version and let me know how it goes? I'm happy to help you debug from there.

Since it's been a couple years, I'm closing this issue for now but I can re-open it at your request :)