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

Doesn't work in browser #75

Open
ajoslin103 opened this issue Jul 28, 2021 · 7 comments
Open

Doesn't work in browser #75

ajoslin103 opened this issue Jul 28, 2021 · 7 comments

Comments

@ajoslin103
Copy link

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;

@ryu1kn
Copy link
Owner

ryu1kn commented Nov 22, 2021

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.

@ajoslin103
Copy link
Author

ajoslin103 commented Nov 22, 2021 via email

@ouroboroscoding
Copy link

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

@ouroboroscoding
Copy link

ouroboroscoding commented Mar 19, 2022

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
  }

@ouroboroscoding
Copy link

@ryu1kn I have added a pull request with a fix for this issue.

#84

@ouroboroscoding
Copy link

FYI, I have forked and published csv-writer-browser in order to be able to continue my development.

@brakmic
Copy link

brakmic commented Jul 16, 2024

Hi @ajoslin103,

This project seems to be abandoned, so I decided to fork it. My version fixes the browser compatibility issue and addresses other problems. I'm also incorporating the unmerged PRs from the original project.

Check it out here:

Give it a try and let me know if you run into any issues.

Best,
Harris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants