json2csv: Dependencies not found : @json2csv/formatters/default.js in BaseParser.js

I run into an error after migrating from json2csv v5.0.7 (that was working nicely)

Using @json2csv/node v6.1.2 Node version v16.19.1

Here is the code I am using (within a VueJS / Nuxt web app) :

import { AsyncParser } from '@json2csv/node';
...
const parser = new AsyncParser();
const csv = await parser.parse(this.data).promise();

When trying to start the web app (npm run dev), I get this error :

 ERROR  Failed to compile with 5 errors

These dependencies were not found: 

* @json2csv/formatters/default.js in ../node_modules/@json2csv/plainjs/src/BaseParser.js 
* @json2csv/formatters/number.js in ../node_modules/@json2csv/plainjs/src/BaseParser.js
* @json2csv/formatters/object.js in ../node_modules/@json2csv/plainjs/src/BaseParser.js
* @json2csv/formatters/string.js in ../node_modules/@json2csv/plainjs/src/BaseParser.js
* @json2csv/formatters/symbol.js in ../node_modules/@json2csv/plainjs/src/BaseParser.js

And indeed, this is what I see when looking into my node_modules folder to check the json2csv BaseParser :

import defaultFormatter from '@json2csv/formatters/default.js';
import numberFormatterCtor from '@json2csv/formatters/number.js';
import stringFormatterCtor from '@json2csv/formatters/string.js';
import symbolFormatterCtor from '@json2csv/formatters/symbol.js';
import objectFormatterCtor from '@json2csv/formatters/object.js';

...

Looking at the files structure, there doesn’t seem to be any JS file at the root of the package, only within dist / src.

image

Expected the sample code to compile and run Actual output : error message mentioned above

Am I doing something wrong here or is there really an import problem within the lib ?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 21 (9 by maintainers)

Most upvoted comments

Popping in to say that I was facing similar issues as @Rapol, but upgrading to jest@29 also fixed my issues