I've been building a basic weather api with React and TypeScript. I have utilized "npx create-react-app . typescript" for the setup. After building out my application I started it up. Initially I had success contacting the api however as I tried to save the api calls using fs.writeFile in addition to fs.readFile to collect the data I ran into the error that said it cannot resolve 'fs'.
current ts.config
{
"compilerOptions": {
"paths": {
"crypto": [
"./node_modules/crypto-browserify"
],
},
"target": "ES2016",
"lib": [
"dom",
"dom.iterable",
"esnext",
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noResolve" : false,
"types": ["node"],
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"downlevelIteration": true,
},
"include": [
"src"
],
"exclude":["node_modules"]
}
Tried to reset using npm install --save fs.
Deleted node_modules, package.lock.json, removed "fs": "0.0.1-security", and reinstalled. This actually seemed to work but then fs wouldn't be recognized and I reinstalled then got a new error which is progress lol.
Error with getWeather, TypeError: fs__WEBPACK_IMPORTED_MODULE_1___default(...).readFile is not a function at postWeather (App.tsx:51:1) at App.tsx:25:1
I have checked stack overflow for existing material such as Module not found: Error: Can't resolve 'fs' in.
The methods there haven't been successful and I am still searching for alternative ways but if anyone could give some advise I would appreciate it.