(ERROR in multi) Module not found: Error: Can't resolve 'babel/loader'

梦想的初衷 提交于 2021-01-29 07:51:56

问题


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]

Note than I have installed babel/loader inside node_modules. Any clue would be appreciated! Thanks in advance.


回答1:


This is the correct formula, after all, below scss you are well declared

{
  test: /\.js$/,
  exclude: /node_modules/,
  use: {
    loader: 'babel-loader',
  },
},

I suggest adding the presets in a separate file. Create .babelrc file and add to it.

{
 "presets": [
   [
    "@babel/preset-env"
   ]
 ]
}

Look here - example




回答2:


Please note that I also had the same problem so to resolve it I installed babel-loader according to their website (see https://github.com/babel/babel-loader):

npm install -D babel-loader @babel/core @babel/preset-env webpack


来源:https://stackoverflow.com/questions/58230055/error-in-multi-module-not-found-error-cant-resolve-babel-loader

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!