Module not found: Error: Can't resolve React-js?
ERROR in multi.src/index.js Module not found: Error: Can't resolve '.src/index.js' in 'G:\new-react\reactquiz' @ multi.src/index.js main[0]
ERROR in multi (webpack)-dev-server/client?http://localhost:8080.src/index.js Module not found: Error: Can't resolve '.src/index.js' in 'G:\new-react\reactquiz' @ multi (webpack)-dev-server/client?http://localhost:8080.src/index.js main[1] i 「wdm」: Failed to compile.
webpack.config.js
module.exports = {
entry: [
'.src/index.js'
],
output:{
path: __dirname,
filename: 'app/js/main.js'
},
module:{
rules: [
{ test: /\.css$/, use: 'css-loader' },
{ test: /\.ts$/, use: 'ts-loader' }
]
}
}
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App.jsx';
ReactDOM.render(
<App />,
document.getElementById('app')
);
App.js
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
class App extends Component{
render(){
return(
<div>
APP
</div>
)
}
}
export default App
You'll have to mention the right path for your src folder. ../src
or whatever your path is
Check below config
module.exports = {
entry: [
'./src/index.js'
],
output:{
path: __dirname,
filename: 'app/js/main.js'
},
module:{
rules: [
{ test: /\.css$/, use: 'css-loader' },
{ test: /\.ts$/, use: 'ts-loader' }
]
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.