(多错误)找不到模块:错误:无法解析“babel/loader"
问题描述:
此图片 包含文件夹结构和 webpack.config.js 文件.当我打开 webpack-dev-server 时,出现以下错误:
This image contains folder structure and webpack.config.js file. When I open webpack-dev-server, I get the following error:
ERROR in multi (webpack)-dev-server/client?http://localhost:8080 ./src/js/index.js ./src/scss/master.scss
Module not found: Error: Can't resolve 'babel/loader' in 'C:\wamp64\www\o\omd'
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/js/index.js ./src/scss/master.scss main[0]
请注意,我在 node_modules
中安装了 babel/loader
.任何线索将不胜感激!提前致谢.
Note than I have installed babel/loader
inside node_modules
. Any clue would be appreciated!
Thanks in advance.
答
这是正确的公式,毕竟在scss
下面你声明得很好
This is the correct formula, after all, below scss
you are well declared
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
我建议在单独的文件中添加预设.创建 .babelrc
文件并添加到其中.
I suggest adding the presets in a separate file. Create .babelrc
file and add to it.
{
"presets": [
[
"@babel/preset-env"
]
]
}
看这里 - 示例