'Buffer is not defined' or 'nodebuffer is not supported by this browser' webpack / angular #614
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#614
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I can't seem to get away from either of these errors.
I'm using webpack and angular.
When I put
node: { Buffer: false }
into my webpack config, I see theBuffer is not defined
error upon loading my app.When I take that out, I see the
nodebuffer is not supported by this browser
when trying to utilize the XLSX methods.I read the other issues mentioning that a buffer shim was being added somewhere else. I did tell webpack not to include jszip as outlined in the demo for webpack using
noParse: [/jszip.js$/]
in my webpack config.Any help would be appreciated. relevant files attached.
xlsx-issue.zip
In general the
nodebuffer is not supported by this browser
error suggests one of the following happened:XLSX.readFile
orXLSX.writeFile
in the browser (since there's no equivalent offs
in the browser context -- you have to get the data another way, like HTML5 File API, and useXLSX.read
orXLSX.write
)XLSX.read
orXLSX.write
withtype:buffer
I actually don't see any reference to
readFile
orwriteFile
orbuffer
in the shared code, so this is strange.Webpack is complaining about your config:
I am not really familiar with either webpack or angular. What version of webpack/angular are you using and how are you running it?
Webpack: 1.14.0
Angular 1.6.0
I'm using webpack-dev-server to bundle and serve the built file locally and including it in the webpage
@mhenris there were many missing pieces from your zip, and I think some of the files in subdirectories were changed, but after some changes and npm installs I was finally able to get webpack to produce something.
I think a buffer shim is being forced by jsforce:
We will have to revisit zip soon.
Just out of curiosity, if you take a file and save it as XLS (not XLSX) do you see any error? XLS doesn't use any zip-related features.
There is no error with .xls file. Only xlsx.
Sorry for the missing stuff, here's a more comprehensive zip file with the package.json and other components, but I think you've figured something out related to JSforce. If I remove it from my list of modules and add the
node: { Buffer: false }
back into webpack.config, then I am able to successfully parse .xlsx files.webapp.zip
We will change how node is detected (using
process
) so that should skip the relevant code paths in the browser