Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Browserify) (JSZip bug) Can't resolve 'util' #12

Open
DoruPirvu opened this issue Nov 2, 2018 · 1 comment
Open

(Browserify) (JSZip bug) Can't resolve 'util' #12

DoruPirvu opened this issue Nov 2, 2018 · 1 comment

Comments

@DoruPirvu
Copy link

ERROR in ./node_modules/readable-stream/lib/_stream_readable.js
Module not found: Error: Can't resolve 'util' in 'D:\.....\node_modules\readable-stream\lib'
 @ ./node_modules/readable-stream/lib/_stream_readable.js 72:16-31
 @ ./node_modules/readable-stream/readable-browser.js
 @ ./node_modules/stream-browserify/index.js
 @ ./node_modules/jszip/lib/readable-stream-browser.js
 @ ./node_modules/jszip/lib/support.js
 @ ./node_modules/jszip/lib/index.js
 @ ./node_modules/read-excel-file/modules/unpackXlsxFileBrowser.js
 @ ./node_modules/read-excel-file/modules/readXlsxFileBrowser.js
 @ ./node_modules/read-excel-file/index.js
 @ ./src/components/Forms/CreateAccount/Upload/index.js
 @ ./src/components/Forms/CreateAccount/Dialog/index.js
 @ ./src/app/routes/tenant/routes/account/list/components/accountListTable.js
 @ ./src/app/routes/tenant/routes/account/list/index.js
 @ ./src/app/routes/tenant/index.js
 @ ./src/app/index.js
 @ ./src/containers/App.js
 @ ./src/MainApp.js
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://localhost:3000 webpack/hot/dev-server babel-polyfill webpack/hot/only-dev-server react-hot-loader/patch ./index.js

ERROR in ./node_modules/readable-stream/lib/internal/streams/BufferList.js
Module not found: Error: Can't resolve 'util' in 'D:\........\node_modules\readable-stream\lib\internal\streams'
 @ ./node_modules/readable-stream/lib/internal/streams/BufferList.js 6:11-26
 @ ./node_modules/readable-stream/lib/_stream_readable.js
 @ ./node_modules/readable-stream/readable-browser.js
 @ ./node_modules/stream-browserify/index.js
 @ ./node_modules/jszip/lib/readable-stream-browser.js
 @ ./node_modules/jszip/lib/support.js
 @ ./node_modules/jszip/lib/index.js
 @ ./node_modules/read-excel-file/modules/unpackXlsxFileBrowser.js
 @ ./node_modules/read-excel-file/modules/readXlsxFileBrowser.js
 @ ./node_modules/read-excel-file/index.js
 @ ./src/components/Forms/CreateAccount/Upload/index.js
 @ ./src/components/Forms/CreateAccount/Dialog/index.js
 @ ./src/app/routes/tenant/routes/account/list/components/accountListTable.js
 @ ./src/app/routes/tenant/routes/account/list/index.js
 @ ./src/app/routes/tenant/index.js
 @ ./src/app/index.js
 @ ./src/containers/App.js
 @ ./src/MainApp.js
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://localhost:3000 webpack/hot/dev-server babel-polyfill webpack/hot/only-dev-server react-hot-loader/patch ./index.js
webpack: Failed to compile.

Context:
npm version = 5.6.0

"engines": {
"node": ">=6.9.0",
"npm": ">= 3"
}

@catamphetamine
Copy link
Owner

jszip module uses "streams" which are included in Node.js but are not included in a browser.
Bundlers (for example, webpack) seem to have their own internal list of modules for which they have a built-in substitution and stream module seems to be one of them.
https://unpkg.com/jszip@3.1.5/lib/readable-stream-browser.js
So, when Webpack sees require('stream') it replaces it with its own substitute.
Seems that you're using "browserify" bundler which substitutes require('stream') with stream-browserify module.
And stream-browserify uses readable-stream internally which uses a native Node.js module called util which is not available in a browser too.
Now, I guess Webpack would substitute util with something else but Browserify seems to not do that.

See the original issue in readable-stream repo:
nodejs/readable-stream#356
I left my comment there.

@catamphetamine catamphetamine changed the title Can't resolve 'util' [JSZip bug] Can't resolve 'util' May 13, 2019
@catamphetamine catamphetamine changed the title [JSZip bug] Can't resolve 'util' (Browserify) (JSZip bug) Can't resolve 'util' Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants