Getting this error:
ERROR in multi main Module not found: Error: Cannot resolve module 'react' in C:\\Users\\username\\Deskto p\\reactApp @ multi main
module.exports = config;
var config = {
entry: './main.js',
output: {
path:'./',
filename: 'index.js',
},
devServer: {
inline: true,
port: 8080
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'react',
query: {
presets: ['es2015', 'react']
}
}]
}
}
Node version - 4.4.7
npm version - 3.10.5
Babel Loaded globally npm install -g babel
npm install -g babel-preset-react
You can try changing the loader to 'babel'
module.exports = config;
var config = {
entry: './main.js',
output: {
path:'./',
filename: 'index.js',
},
devServer: {
inline: true,
port: 8080
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}]
}
}
This is how mine is setup and it works for me.
Edit:
This is my full webpack setup:
module.exports = {
entry: [
'./src/index.js'
],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
module: {
loaders: [{
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['react', 'es2015', 'stage-1']
}
},{
include: /\.json$/,
loaders: ["json-loader"]
},{
test: /(\.css)$/, loaders: ['style', 'css']
}]
},
resolve: {
extensions: ['', '.json', '.js', '.jsx']
},
devServer: {
historyApiFallback: true,
contentBase: './'
}
};
With the following dependencies that relate to babel and webpack (not the full list)
"devDependencies": {
"babel-core": "^6.2.1",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"babel-preset-stage-1": "^6.1.18",
"json-loader": "^0.5.4",
}
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.