I have used import * as fs from 'fs';, import fs from 'fs';, import { readFile } from 'fs';, const fs = require('fs'); & const fs = (window).require('fs');, but none of them runs correctly.
The application created by create-react-app, one is JavaScript Version another one is TypeScript Version. I want know how to solve this issue, and the reason of its cause.
When using import * as fs from 'fs'; & import fs from 'fs', it shows TypeError: fs.readFile is not a function.
When using import { readFile } from 'fs';, it shows Uncaught TypeError: Object(...) is not a function.
When using const fs = (window).require('fs');, it shows window.require is not a function.
When using const fs = require('fs');, it shows fs__WEBPACK_IMPORTED_MODULE_1__.readFile is not a function.
Whether is the matter of config file of project or tsconfig? Thanks for your help.