I've been banging my head over my table trying to figure out whats wrong here, and I need some help pls :')
I'm trying to convert a CSV file to JSON, and all of the packages seem to use something called "fs". I've searched the web and tried all of the following fixes, but nothing seems to work. I'm using webpack 5.74 btw.
Node cannot find module "fs" when using webpack
https://github.com/webpack-contrib/css-loader/issues/447
No matter what I try, I always get the "Cannot find module 'fs'" error.
Does anyone have an idea of what this could be, since I've tried all of the possible solutions in the links above?
Any help would be much appreciated! Thank you!
------ UPDATE--------
const csvtojson = require("csvtojson");
const fs = require('fs');
const handleParse = () => {
if (!file) return setError("Enter a valid file");
csvtojson().fromFile(csvfilepath).then((json) => {
console.log(json);
fs.writeFileSync("./teamInformation.json", JSON.stringify(json), "utf-8", (err) => {
if (err) {
console.log(err);
}
});
});
};
This is the code that I've been using the package for, converting the CSV file at a file path (which I've omitted here) to a JSON file
Via Active questions tagged javascript - Stack Overflow https://ift.tt/wGkElhJ
Comments
Post a Comment