Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Module not found: Error: Can't resolve 'stream' in node_modules\csv-parse\lib\es5 #302

Closed
kzkzg opened this issue Nov 13, 2020 · 10 comments · Fixed by Sidoine/Ovale#845, pedrohenriquerls/troublemaker_bot#7 or newerton/gostack-template-typeorm-upload#18
Labels

Comments

@kzkzg
Copy link

kzkzg commented Nov 13, 2020

After update from Angular 5 to 6, I have this compile error.

ERROR in ./node_modules/csv-parse/lib/es5/index.js Module not found: Error: Can't resolve 'stream' in '<projectPath>\node_modules\csv-parse\lib\es5'

Package version 4.14.0
What am I doing wrong? Please help

@kzkzg kzkzg added the bug label Nov 13, 2020
@wdavidw
Copy link
Member

wdavidw commented Nov 13, 2020

You seem to be in a browser environnement. You need to use sth like webpack.

@kzkzg
Copy link
Author

kzkzg commented Nov 13, 2020

You seem to be in a browser environnement. You need to use sth like webpack.

I'm staring it by ng serve from angular

@wdavidw
Copy link
Member

wdavidw commented Nov 13, 2020

Try to use a tool like browserify

@igabesz
Copy link

igabesz commented Dec 2, 2020

Angular has a preconfigured build system that is not to be tampered with in most cases. If it won't work with the default builder then this package is practically unusable in Angular.

@darkguy2008
Copy link

darkguy2008 commented Feb 20, 2021

I agree, just stumbled upon this issue as well. Such a good library that comes up in search results but it's practically unusable in Angular or anything that doesn't require custom webpack modifications, and the workaround of using browserify is just laughable, and sad. Any known alternatives?

Edit: For future readers, I ended up using https://www.npmjs.com/package/csvtojson

@wdavidw
Copy link
Member

wdavidw commented Feb 22, 2021

No wait! I made it worked for csv-stringify. Give me an hour and I will publish a working version with a demo.

@wdavidw
Copy link
Member

wdavidw commented Feb 22, 2021

I just published version v4.15.2, you can have a look at this demo. It uses the HTML <script> tag without any external code and it gives access to the parse function. Let us know if it works for you with angular.

@webstoreportal
Copy link

Another issue-reply mentioned to use es5 - that did not work

Assuming node issues. Hard to track down any recent workarounds with this or in general for Angular projects

lib/browser seems to get past the initial prototype etc resolution issues with csv; however, it does not have a declaration file for poor importability?

Angular TypeScript

may be better to use one of the many angular csv packages around

@webstoreportal
Copy link

Adding here as a faster workaround to get up and running from a search engine search -
I used Papa Parse - explicitly advertised for in-browser parsing

npm i papaparse

It just works. 600k weekly downloads. Simple single dependency. Seems extremely fast. Decent intellisense usage with documented comments and the documentation first page overview easy to use.

Would have preferred to use something well-supported like csv, 300k weekly downloads with a great name; however, the hours saved for a simple import into web app usage in this personal use case are indisputable.

May come back to csv for node-specific usage

@wdavidw
Copy link
Member

wdavidw commented Jun 17, 2021

You can also help by providing a simple angular repository reproducing the problem, from there, I can work on it to better understand what the problem is and fix it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.