TypeError: Object doesn't support property or method 'readFile'
I've just created a brand new react app, but this is happening... I don't know what else I can do.
import * as React from "react";
import * as fs from "fs";
import * as zlib from 'zlib';
constructor(props: IReactComponentProps, state: IReactComponentState) {
super(props, state);
this.jsonPath = "/myfolder/mygzipedjsonfile.json.gz";
this.state = {
loading: true,
error: false,
};
this.test();
}
private test() {
fs.readFile(this.jsonPath, function (err, buffer) {
console.log('success');
});
}
Error: TypeError: Object doesn't support property or method 'readFile'
ReactComponent.prototype.test
C:/Source/new-teste/src/ReactComponent.tsx:44
41 |
42 | private test() {
43 |
> 44 | fs.readFile(this.jsonPath, function (err, buffer) {
| ^
<input type="file">element and have the user select the file. Javascript in the browser can't select files without the user's permission. - sissonb