当我尝试从webpack3升级到webpack4时出错

时间:2018-10-05 06:53:39

标签: reactjs webpack webpack-4 babel-loader

将项目从webpack 3.x升级到webpack 4.0.0时,出现以下错误消息

    ERROR in multi script-loader!jquery/dist/jquery.min.js script-loader!foundation-sites/dist/js/foundation.min.js eventsource-polyfill webpack-hot-middleware/client?reload=true ./src/index.jsx
Module not found: Error: Can't resolve 'babel-loader' in 'C:\projects\rebasing\uisrc'
 @ multi script-loader!jquery/dist/jquery.min.js script-loader!foundation-sites/dist/js/foundation.min.js eventsource-polyfill webpack-hot-middleware/client?reload=true ./src/index.jsx

规则配置如下所示在配置文件中

rules: [
  {
    test: /\.(jsx?)$/,
    use: 'babel-loader',
    exclude: /node_modules/,
  },
]

Package.json具有以下库

"devDependencies": {
"babel-cli": "6.26.0",
"babel-core": "6.8.0",
"babel-eslint": "7.0.0",
"babel-loader": "7.1.5",
"babel-preset-es2015": "6.6.0",
"babel-preset-react": "6.5.0",
"babel-preset-react-hmre": "1.1.1",
"babel-preset-stage-0": "6.5.0",
"babel-preset-stage-2": "6.17.0",
"babel-register": "6.26.0",
}

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:1)

在webpack4中,配置应为// here I expect the see the selected item start at the first item // in the UI in index order and move quickly down through the // list until it stops at the last one. This doesn't happen. The UI remains // unaffected. ClientModule.CDSData.First; while not ClientModule.CDSData.Eof do begin ClientModule.CDSData.Next; Sleep(100); end; ,而不是loader: "babel-loader"

use: "babel-loader"

这是我的webpack4演示

我正在使用的版本

  

“ webpack”:“ ^ 4.15.0”,

     

“ webpack-cli”:“ ^ 3.0.8”,

     

“ webpack-dev-server”:“ ^ 3.1.4”,

     

“ babel-core”:“ ^ 6.26.3”,

     

“ babel-loader”:“ ^ 7.1.5”,

     

“ babel-plugin-transform-class-properties”:“ ^ 6.24.1”,

     

“ babel-plugin-transform-object-rest-spread”:“ ^ 6.26.0”,

     

“ babel-polyfill”:“ ^ 6.26.0”,“ babel-preset-env”:“ ^ 1.7.0”,

     

“ babel-preset-react”:“ ^ 6.24.1”

  rules: [
        {
            //tell webpack to use jsx-loader for all *.jsx files
            test: /\.(jsx?)$/,
            exclude: /node_modules/,
            loader: "babel-loader"
        },
   ]

答案 1 :(得分:0)

如果还没有,请尝试清除node_modules缓存并重新安装:

CultureInfo ci=new CultureInfo("en-US");
Xamarin.Forms.DependencyService.Get<ILocalize>().SetLocale(ci);                      
AppResources.Culture = ci;