TypeError:对象不支持属性或方法“ readFile”
我刚刚创建了一个全新的react应用,但这正在发生... 我不知道还能做什么。
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');
});
}
错误:TypeError:对象不支持属性或方法“ 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) {
| ^