read-excel-file
read-excel-file copied to clipboard
(Browserify) (JSZip bug) Can't resolve 'util'
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" }
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/[email protected]/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:
https://github.com/nodejs/readable-stream/issues/356
I left my comment there.