I have just began learning React, and have stumbled upon this error while trying to build using webpack.
Module not found: Error: Can't resolve 'Home' in 'D:\wamp64\www\Wallet\src\components'
resolve 'Home' in 'D:\wamp64\www\Wallet\src\components'
My webpack.config.js:
const path = require('path');
module.exports = {
entry: {
index: '.src/index.js',
js: './src/js/index2.js',
react: './src/components/App.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['env', 'stage-0', 'react']
}
}
]
}
};
My Home.js:
const Home = () => {
return <h1>Home</h1>
}
export default Home
This is how I've imported Home in App.js:
import { BrowserRouter, Route, Switch , Link} from 'react-router-dom';
import Home from 'Home';
import About from 'About';
I came across few questions on here, which suggested adding an empty index.js in src folder, but that too didn't work.