Fs import error despite being recognized in code

In my .ts file, the fs import is recognized

import * as fs from "fs";

but when I do ionic serve, I’m getting an error in the console that says:

[react-scripts] Module not found: Error: Can't resolve 'fs' in '/mnt/c/Users/dabas/Documents/programming/mobile/islamic-texts/src/composables'
[react-scripts] webpack compiled with 1 error and 1 warnin

How do I get fs to work when it’s already recognized in the file?

What are you trying to do with fs? fs is useful for server-side rendering, not client-side rendering, which is what Ionic React does.

If you need access to the device filesystem, you’ll want to use something like @capacitor/filesystem.

1 Like