I am learning typescript and currently trying to import simple json file which I store locally in the project bootstrapped with create-react-app.
data.json looks like this:
{
"test": "123",
}
In my App.tsx I am trying to import it using json-loader. Both App.tsx and data.json are in the same folder and the import looks like this:
import data from './data.json'
I've already tried couple solutions to this problem but nothing seems to work. Those solutions are import * as data from './data.json' and const data = require('./data.json')
create-react-appconfiguration? You may need to share the portion of the webpack configuration where you addedjson-loader. You import statement looks right StackBlitzvar data = require('./data.json');try thisimport * as data from './data.json'I can console.log the data BUT the error is...containers/App.tsx(3,23): Cannot find module './data.json'.create-react-appproject? You should probably share you configuration so others can help answer your issue.create-react-app my-app --scripts-version=react-scripts-tsWhen I try to import like you did in your sandbox it gives meCannot find module'./data.json' error.