I\'m trying to load languages.json file in a React component. I\'m getting the following error at the very first step when I want to import the json file. Here is the error:
azium is correct that a loader is needed, but here's the configuration for good measure:
npm command
> npm install json-loader --save-dev
webpack.config.js
module.exports = {
....
resolve: {
extensions: ['', '.js', '.jsx', '.json']
},
...
module: {
...
{
test: /\.json$/,
loader: 'json'
}
...
}
}
By adding the json
extension to resolve
, you won't need to specify it in your import
statement.