I have an error when configuring a webpack with Reactjs. I get this error that is below and would like an explanation.
The error that comes to me in the terminal is the following:
ERROR in Entry module not found: Error: Can't resolve 'C:\react\index.js'
in 'C:\react' npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR!
[email protected] build:prod: webpack -p --env.NODE_ENV=production npm
ERR! Exit status 2 npm ERR! npm ERR! Failed at the [email protected]
build:prod script. npm ERR! This is probably not a problem with npm.
There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR!
C:\AppData\Roaming\npm-cache_logs18-07-22T21_33_42_548Z-debug.log
Here I leave as is my webpack.config
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = (env) => {
const plugins = [
new ExtractTextPlugin("css/[name].[hash].css")
]
if (env.NODE_ENV === 'production') {
plugins.push(
new CleanWebpackPlugin(['dist'], {root: __dirname})
)
}
return {
entry: {
"plaztivideo": path.resolve(__dirname, 'index.js'),
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'js/[name].[hash].js',
publicPath: path.resolve(__dirname, 'dist')+"/",
chunkFilename: 'js/[id].[chunkhash].js',
},
devServer: {
port: 9000,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['es2015', 'react', 'stage-2'],
}
},
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
minimize: true,
}
}
]
})
},
{
test: /\.(jpg|png|gif|svg)$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
fallback: 'file-loader',
name: 'images/[name].[hash].[ext]',
}
}
},
]
},
plugins
}
}