(多错误)找不到模块:错误:无法解析“babel/loader" [英] (ERROR in multi) Module not found: Error: Can't resolve 'babel/loader'

查看:65
本文介绍了(多错误)找不到模块:错误:无法解析“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"
   ]
 ]
}

看这里 - 示例

这篇关于(多错误)找不到模块:错误:无法解析“babel/loader"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆