I have
import fs from \'fs\'
and in my package.json I have
Then I run the command
In create-react-app
they have stubbed out 'fs'. You cannot import it.
They did this because fs
is a node core module.
You'll have to find another solution to that problem. See this ticket.
It's possible this might be an environment issue. It's not possible for the browser to interpret and run some Node server-side modules like fs
.
The solution is to run the fs
methods in a Node environment (server-side) or to find a package which offers the same functionality but written for the browser.
It's discussed in this question... Module not found: Error: Cannot resolve module 'fs'
And this question... Use fs module in React.js,node.js, webpack, babel,express