I've written the following app to display a local csv file in the form of cards(https://www.npmjs.com/package/react-card-slider-component) , but I'm getting an error with file system module (Module not found: Error: Can't resolve 'fs')
Doing the following didn't help : import fs from "fs";
Here's my code :
import fs from "fs";
import ReactCardSlider from 'react-card-slider-component';
function App(){
const sliderClick = (slider)=>{
alert("hello world");
}
const fs = require('fs');
const data = fs.readFileSync('F:/result.csv', 'utf8');
console.log(data);
var csv = require('jquery-csv');
var slides = csv.toObjects(data);
return (
<div id="body">
<ReactCardSlider slides={slides}/>
</div>);
}
export default App;
CodePudding user response:
browsers does not allow you to interact directly with files in the system like node.js, but you can use libraries that use the browser file system api, like browser-fs-access and browserfs
CodePudding user response:
import * as fs from "fs"
//if CommonJS
const fs = require("fs")