node-csv icon indicating copy to clipboard operation
node-csv copied to clipboard

Build fails in CI "Property 'on' does not exist on type 'Parser'"

Open aryobenholzner opened this issue 3 years ago • 5 comments

Describe the bug

When using the csv library for a frontend app with Vue, I get build errors on multiple CI environments. When running the build command locally, it's working fine. In all CI environments I tried (Github Actions, Azure Pipelines, Cloudflare Pages), I get an error when runnung npm run build

src/services/my-parser.ts(61,16): error TS2339: Property 'on' does not exist on type 'Parser'.
src/services/my-parser.ts(63,37): error TS2339: Property 'read' does not exist on type 'Parser'.
src/services/my-parser.ts(68,16): error TS2339: Property 'on' does not exist on type 'Parser'.
src/services/my-parser.ts(73,16): error TS2339: Property 'on' does not exist on type 'Parser'.

To Reproduce

I made a Vue Project with Vite as build system using pnpm create vite my-vue-app --template vue-ts. I tried using '[email protected]' as well as ' [email protected]'.

I use import according to docs from csv-parse/browser/esm and then use the parse() and parser.on() as well as parser.read()

Additional context

Locally, the build works regardless. I tried using pnpm as well as npm without success

aryobenholzner avatar Aug 08 '22 18:08 aryobenholzner

Sorry but unless you provide me a script replicating the issue, it will be hard for us to investigate.

wdavidw avatar Aug 08 '22 18:08 wdavidw

Sorry, I was in a hurry. I now created a sample repo as described https://github.com/aryobenholzner/vue-csv. Notice the github action fails when running npm run build

aryobenholzner avatar Aug 08 '22 19:08 aryobenholzner

any updates on this? i would really like to use this package in client

aryobenholzner avatar Sep 10 '22 20:09 aryobenholzner

Nope, I don't have much time lately. Moreover, this is a TS compilation error, and I am no expert in that matter.

wdavidw avatar Sep 12 '22 12:09 wdavidw

@aryobenholzner Parser extends stream.Transform from Node, the on method comes from stream.Transform.

By default, these Node types are missing.

To add the missing Node types, simply install the @types/node package.

npm install -D @types/node

It might make sense to add @types/node into the dev dependencies of this library but I don't know whether it is a best practice.

jhrdina avatar Sep 17 '23 19:09 jhrdina