Webpack、React、Babel - 无法解析模块
Webpack, React, Babel - Cannot Resolve module
我已经安装了 react-hot-loader 并引用了 webpack.config.js 中的模块。但是,当我尝试 运行 webpack 编译脚本时,出现错误。
请看下面的屏幕截图。有人可以告知问题可能是什么。仅供参考,我正在使用所有最新的库。
[1]: http://i.stack.imgur.com/2GCa1.jpg
/*webpack.config.js
module.exports = {
devtool: 'eval-source-map',
entry: {
main: [
'./src/main.js'
]
},
output: {
filename: './public/[name].js'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: ['react-hot','babel-loader'],
query: {
presets: ['es2015', 'react']
}
}
]
}
}
/*UPDATE*/
Code update
I have added an "s" after loader. It is now giving me the below error.
[2]: http://i.stack.imgur.com/LL1nn.jpg
我用 webpack、babel 和 react-hot-loader 创建了一个启动器。请查看我的配置:https://github.com/skrobek/webpack-react/blob/master/webpack.config.js
和package.jsonhttps://github.com/skrobek/webpack-react/blob/master/package.json#L19
随意使用它:-)
根据您的第二张图片,您可以尝试以下操作:
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: ['react-hot'],
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: ['babel-loader'],
query: {
presets: ['es2015', 'react']
}
}
]
我已经安装了 react-hot-loader 并引用了 webpack.config.js 中的模块。但是,当我尝试 运行 webpack 编译脚本时,出现错误。
请看下面的屏幕截图。有人可以告知问题可能是什么。仅供参考,我正在使用所有最新的库。
[1]: http://i.stack.imgur.com/2GCa1.jpg
/*webpack.config.js
module.exports = {
devtool: 'eval-source-map',
entry: {
main: [
'./src/main.js'
]
},
output: {
filename: './public/[name].js'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: ['react-hot','babel-loader'],
query: {
presets: ['es2015', 'react']
}
}
]
}
}
/*UPDATE*/
Code update
I have added an "s" after loader. It is now giving me the below error.
[2]: http://i.stack.imgur.com/LL1nn.jpg
我用 webpack、babel 和 react-hot-loader 创建了一个启动器。请查看我的配置:https://github.com/skrobek/webpack-react/blob/master/webpack.config.js
和package.jsonhttps://github.com/skrobek/webpack-react/blob/master/package.json#L19
随意使用它:-)
根据您的第二张图片,您可以尝试以下操作:
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: ['react-hot'],
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: ['babel-loader'],
query: {
presets: ['es2015', 'react']
}
}
]