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

TypeError: Object prototype may only be an Object or null: undefined #57

Open
kaiyoma opened this issue Oct 19, 2021 · 7 comments
Open

Comments

@kaiyoma
Copy link

kaiyoma commented Oct 19, 2021

I'm currently trying to upgrade my project to webpack 5 and I'm now running into a bizarre compilation error with this package. When I start my app, I see this in the browser console:

TypeError: Object prototype may only be an Object or null: undefined
    at setPrototypeOf (<anonymous>)
    at extendStatics (Streamer.js?fc49:7)
    at __extends (Streamer.js?fc49:10)
    at eval (Streamer.js?fc49:20)
    at eval (Streamer.js?fc49:72)
    at Object../node_modules/.pnpm/[email protected]/node_modules/csv-string/dist/Streamer.js (bundle.js:47851)
    at __webpack_require__ (bundle.js:93000)
    at fn (bundle.js:93290)
    at eval (CSV.js?a8d5:4)
    at Object../node_modules/.pnpm/[email protected]/node_modules/csv-string/dist/CSV.js (bundle.js:47829)

The error appears to be coming from deep inside csv-string. What does this error mean?

@holub008
Copy link

In case it helps, I'm also here with a webpack 5 issue, albeit with a better error message:

[1] ERROR in ./node_modules/csv-string/dist/Streamer.js 33:15-32
[1] Module not found: Error: Can't resolve 'stream' in '{omited}/node_modules/csv-string/dist'
[1] 
[1] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
[1] This is no longer the case. Verify if you need this module and configure a polyfill for it.

I'm guessing the webpack 5 bump you made removed the stream polyfill that this lib depends on.

I'm probably going to move on to a new CSV writer (easy for my project) unless maintainers have plans to break out a module that doesn't have this dependency?

@andrewdowis
Copy link

andrewdowis commented Mar 2, 2023

@kaiyoma @holub008 I am experiencing the same when upgrading webpack 4 to 5, experiencing the error on the package csv-string - were you able to find a solution, alternate package, or anything?

@kaiyoma
Copy link
Author

kaiyoma commented Mar 2, 2023

@kaiyoma @holub008 I am experiencing the same when upgrading webpack 4 to 5, experiencing the error on the package csv-string - were you able to find a solution, alternate package, or anything?

I gave up on webpack 5 and stayed with 4, until we migrate to something different entirely. 🤷

@holub008
Copy link

holub008 commented Mar 2, 2023

There are endless CSV libraries on the npm registry, I haven't migrated yet but can update here when I find & vet one that doesn't rely on system polyfills.

@kaiyoma
Copy link
Author

kaiyoma commented May 23, 2023

Ha! I just encountered this same problem again while trying to migrate to Vite, and found my old bug. I'm guessing there's still no fix?

@holub008
Copy link

holub008 commented Sep 28, 2023

Alright, I exaggerated. I didn't end up finding any trustworthy CSV writings libs for the client that didn't require polyfill.

So I moved my spreadsheet needs to the server with exceljs (we run on Node) in order to drop csv-string. Generating CSV on the client was a quick and dirty trick made easy by default polyfills in webpack 4, but let's be honest... it was always a hack! FWIW, exceljs is a breeze to use and produces featureful, styled sheets in a variety of formats.

@holub008
Copy link

To addressing your specific need @kaiyoma, I also moved my project to vite (What a shame that CRA maintainers have ghosted it without even a deprecation notice). It looks like adding polyfills should be straightforward: https://www.npmjs.com/package/vite-plugin-node-polyfills

However, I would recommend avoiding polyfills for the sanity of future developers.

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

3 participants