csv-writer
csv-writer copied to clipboard
Doesn't work in browser
Hi,
If would be great if you could release a subset of this package that only included the csvStringifier and removed the dependency on the fs package
Thanks Al;
Hi @ajoslin103 , sorry for my slow response. I wonder if you could just use csvStringifier
. csvWriter
shouldn't cause any troubles if you're not using it in browsers.
:) slow response ok - I can’t remember what I was working on back then - I must have found a way around it
from the comment it looks like I couldn’t use csvStringifier in the browser because it had a dependency on fs which I don’t have when in the browser
it was back in july, so this might have been due to webpack 5 not auto poyfilling node modules
in any case, you can close this issue
cheers!
Al;
On Nov 22, 2021, at 1:27 AM, Ryuichi Inagaki @.***> wrote:
Hi @ajoslin103 https://github.com/ajoslin103 , sorry for my slow response. I wonder if you could just use csvStringifier. csvWriter shouldn't cause any troubles if you're not using it in browsers.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ryu1kn/csv-writer/issues/75#issuecomment-975171248, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADML5KMG24OXDKUJTAA5YTUNHPEFANCNFSM5BEJK4KA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Same issue. I have been using this module for a while, but recently I tried to install it with a newer node (16.14.2) / npm (8.5.0) and I get the following error:
ERROR in ./node_modules/csv-writer/dist/lib/file-writer.js 150:11-24
Module not found: Error: Can't resolve 'fs' in '[project_path]/node_modules/csv-writer/dist/lib'
Parsed request is a module
using description file: [project_path]/node_modules/csv-writer/package.json (relative path: ./dist/lib)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
[project_path]/node_modules/csv-writer/dist/lib/node_modules doesn't exist or is not a directory
[project_path]/node_modules/csv-writer/dist/node_modules doesn't exist or is not a directory
[project_path]/node_modules/csv-writer/node_modules doesn't exist or is not a directory
[project_path]/node_modules/node_modules doesn't exist or is not a directory
looking for modules in [project_path]/node_modules
single file module
using description file: [project_path]/package.json (relative path: ./node_modules/fs)
no extension
[project_path]/node_modules/fs doesn't exist
.web.mjs
[project_path]/node_modules/fs.web.mjs doesn't exist
.mjs
[project_path]/node_modules/fs.mjs doesn't exist
.web.js
[project_path]/node_modules/fs.web.js doesn't exist
.js
[project_path]/node_modules/fs.js doesn't exist
.json
[project_path]/node_modules/fs.json doesn't exist
.web.jsx
[project_path]/node_modules/fs.web.jsx doesn't exist
.jsx
[project_path]/node_modules/fs.jsx doesn't exist
[project_path]/node_modules/fs doesn't exist
/media/bast/bastSSD/workspace/undoo/node_modules doesn't exist or is not a directory
/media/bast/bastSSD/workspace/node_modules doesn't exist or is not a directory
/media/bast/bastSSD/node_modules doesn't exist or is not a directory
/media/bast/node_modules doesn't exist or is not a directory
/media/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
looking for modules in [project_path]/node_modules
single file module
using description file: [project_path]/package.json (relative path: ./node_modules/fs)
no extension
[project_path]/node_modules/fs doesn't exist
.web.mjs
[project_path]/node_modules/fs.web.mjs doesn't exist
.mjs
[project_path]/node_modules/fs.mjs doesn't exist
.web.js
[project_path]/node_modules/fs.web.js doesn't exist
.js
[project_path]/node_modules/fs.js doesn't exist
.json
[project_path]/node_modules/fs.json doesn't exist
.web.jsx
[project_path]/node_modules/fs.web.jsx doesn't exist
.jsx
[project_path]/node_modules/fs.jsx doesn't exist
[project_path]/node_modules/fs doesn't exist
looking for modules in [project_path]/src
single file module
using description file: [project_path]/package.json (relative path: ./src/fs)
no extension
[project_path]/src/fs doesn't exist
.web.mjs
[project_path]/src/fs.web.mjs doesn't exist
.mjs
[project_path]/src/fs.mjs doesn't exist
.web.js
[project_path]/src/fs.web.js doesn't exist
.js
[project_path]/src/fs.js doesn't exist
.json
[project_path]/src/fs.json doesn't exist
.web.jsx
[project_path]/src/fs.web.jsx doesn't exist
.jsx
[project_path]/src/fs.jsx doesn't exist
[project_path]/src/fs doesn't exist
@ ./node_modules/csv-writer/dist/lib/csv-writer.js 148:20-44
@ ./node_modules/csv-writer/dist/lib/csv-writer-factory.js 7:19-42
@ ./node_modules/csv-writer/dist/index.js 9:27-62
@ ./src/format/Results.js 20:0-56 709:25-51
@ ./src/format/index.js 9:0-32 12:0-65
@ ./src/components/Site.js 13:0-28
@ ./src/index.js 7:0-37 10:33-37
After some more research it seems to be related to the latest React more so than node/npm.
Apparently the issue can be resolved by adding the following to the csv-writer package.json
"browser": {
"fs": false
}
If you happen to use any other file system modules those should also be added, i.e.:
"browser": {
"fs": false,
"path": false,
"os": false
}
@ryu1kn I have added a pull request with a fix for this issue.
https://github.com/ryu1kn/csv-writer/pull/84
FYI, I have forked and published csv-writer-browser in order to be able to continue my development.