Answer the question
In order to leave comments, you need to log in
Installing react/webpack, what's the problem?
Please help me understand what is wrong? I install a project with react/redux/webpack/webpck-devserver and I get this error. Already updated everything, nothing helps. I couldn't find a solution to the problem on google.
ERROR in multi main
Module not found: Error: Cannot resolve 'file' or 'directory' E:\Study projects\React-test\node_modules\webpack-dev-server\client\index.js in E:\Study projects\React-test
@ multi main
ERROR in multi main
Module not found: Error: Cannot resolve 'file' or 'directory' ./src/index.js in E:\Study projects\React-test
@ multi main
ERROR in multi main
Module not found: Error: Cannot resolve module 'webpack/hot/dev-server' in E:\Study projects\React-test
@ multi main
ERROR in multi main
Module not found: Error: Cannot resolve module 'webpack-dev-server/client' in E:\Study projects\React-test
@ multi main
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
const NODE_ENV = process.env.NODE_ENV || 'development';
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/dev-server',
'./src/index.js'
],
output: {
publicPath: 'http://localhost:3000/',
path: __dirname + '/public',
filename: 'bundle.js'
},
watch: NODE_ENV == 'development',
watchOptions: {
aggregateTimeout: 100
},
devtool: NODE_ENV == 'development' ? 'cheap-inline-module-source-map' : null,
plugins: [
new webpack.HotModuleReplacementPlugin(),
new ExtractTextPlugin('bundle.css'),
new webpack.DefinePlugin({
NODE_env: JSON.stringify(NODE_ENV)
}),
new webpack.NoErrorsPlugin()
],
resolve: {
moduleDirectories: ['node_modules', 'bower_components'],
moduleTemplates: ['*', 'index'],
extensions: ['*', 'index'],
root: __dirname + '/src'
},
resolveLoader: {
moduleDirectories: ['node_modules', 'bower_components'],
moduleTemplates: ['*-loader', '*'],
extensions: ['', '.js']
},
devServer: {
host: 'localhost',
port: 3000,
contentBase: __dirname + '/public',
inline: true,
hot: true,
historySpiFallback: true
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['react-hot', 'babel-loader'],
include: [
path.resolve(__dirname, 'src')
],
plugins: ['transform-runtime']
},
{
test: /\.(png|jpg|svg|gif)$/,
loaders: 'file?name=img/[path][name].[ext]'
},
{
test: /\.woff(\?v=\d+\.d+\.d+)?$/,
loaders: 'url?limit=10000&mimetype=application/font-woff&name=fonts/[name].[ext]'
},
{
test: /\.woff2(\?v=\d+\.d+\.d+)?$/,
loaders: 'url?limit=10000&mimetype=application/font-woff&name=fonts/[name].[ext]'
},
{
test: /\.ttf(\?v=\d+\.d+\.d+)?$/,
loaders: 'url?limit=10000&mimetype=application/octet-stream&name=fonts/[name].[ext]'
},
{
test: /\.eot(\?v=\d+\.d+\.d+)?$/,
loaders: 'file&name=fonts/[name].[ext]'
},
{
test: /\.svg(\?v=\d+\.d+\.d+)?$/,
loaders: 'url?limit=10000&mimetype=image/svg+xml&name=fonts/[name].[ext]'
}
]
}
};
if(NODE_ENV == 'production'){
console.log('WTF');
module.exports.plugins.push(
new webpack.optimize.__UglifyJsPlugin({
compress: {
warnings: false,
drop_console: true,
unsafe: true
}
})
)
}
Answer the question
In order to leave comments, you need to log in
I can assume that there may be problems in the path (there is a space in the Study projects directory). Try doing all this in a directory with no spaces in the path.
the problem is this line loaders: ['react-hot', 'babel-loader'], install a new version of the [email protected] package from npm and replace this line with loaders: ['react -hot-loader/webpack', 'babel-loader'].
this is definitely wrong - './src/index.js' must be absolute paths.
You already have paths in resolve, so you can just leave 'index.js'. Or, for now, omit the resolve section and use the path module and __dirname variable (just to get a better understanding of the first step)
resolve: {
moduleDirectories: ['node_modules', 'bower_components'],
moduleTemplates: ['*', 'index'],
extensions: ['*', 'index'],
root: __dirname + '/src'
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question