zemirco / json2csv

Convert json to csv with column titles
http://zemirco.github.io/json2csv
MIT License
2.71k stars 366 forks source link

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. #582

Closed madmacc closed 1 year ago

madmacc commented 1 year ago

When serving in a new Angular 16 project I get the following error:

./node_modules/json2csv/lib/JSON2CSVTransform.js:5:4-21 - Error: Module not found: Error: Can't resolve 'stream' in 'mypath\node_modules\json2csv\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

I get the same error 4 times for:

./node_modules/json2csv/lib/JSON2CSVAsyncParser.js:5:4-21 - Error: Module not found: Error: Can't resolve 'stream' in 'mypath\node_modules\json2csv\lib'
./node_modules/json2csv/lib/JSON2CSVBase.js:3:11-24 - Error: Module not found: Error: Can't resolve 'os' in 'mypath\node_modules\json2csv\lib'
./node_modules/json2csv/lib/JSON2CSVTransform.js:5:4-21 - Error: Module not found: Error: Can't resolve 'stream' in 'mypath\node_modules\json2csv\lib'
./node_modules/json2csv/lib/formatters/stringQuoteOnlyIfNecessary.js:1:11-24 - Error: Module not found: Error: Can't resolve 'os' in 'mypath\node_modules\json2csv\lib\formatters'

"json2csv": "^6.0.0-alpha.2",

knownasilya commented 1 year ago

Please see the new repo https://github.com/juanjoDiaz/json2csv

madmacc commented 1 year ago

@knownasilya Thanks for the quick response. Apologies I did not read the notice at the top in NPM. Any instructions on how to install from here as I normally use npm install?

madmacc commented 1 year ago

Figured it out https://juanjodiaz.github.io/json2csv/#/quick-start import { Parser } from '@json2csv/plainjs';