问题描述:
在webpack4版本使用happypack会出现以下错误:
if (resolve.length === 4) {
^
TypeError: Cannot read property 'length' of undefined
at resolveLoader (...\node_modules\happypack\lib\WebpackUtils.js:138:17)
at ...\node_modules\happypack\lib\WebpackUtils.js:126:7
at ...\node_modules\happypack\node_modules\async\lib\async.js:713:13
at async.forEachOf.async.eachOf (...\node_modules\happypack\node_modules\async\lib\async.js:233:13)
at _parallel (...\node_modules\happypack\node_modules\async\lib\async.js:712:9)
at Object.async.parallel (...\node_modules\happypack\node_modules\async\lib\async.js:726:9)
at Object.exports.resolveLoaders (...\node_modules\happypack\lib\WebpackUtils.js:122:9)
at resolveLoaders (...\node_modules\happypack\lib\HappyPlugin.js:137:20)
at ...\node_modules\happypack\node_modules\async\lib\async.js:713:13
at iterate (...\node_modules\happypack\node_modules\async\lib\async.js:262:13)
at async.forEachOfSeries.async.eachOfSeries (...\node_modules\happypack\node_modules\async\lib\async.js:281:9)
at _parallel (...\node_modules\happypack\node_modules\async\lib\async.js:712:9)
at Object.async.series (...\node_modules\happypack\node_modules\async\lib\async.js:734:9)
at HappyPlugin.start (...\node_modules\happypack\lib\HappyPlugin.js:127:9)
at AsyncSeriesHook.eval [as callAsync] (eval at create (...\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:7:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (...\node_modules\tapable\lib\Hook.js:35:21)
at hooks.beforeRun.callAsync.err (...\node_modules\webpack\lib\Compiler.js:194:19)
at AsyncSeriesHook.eval [as callAsync] (eval at create (...\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:15:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (...\node_modules\tapable\lib\Hook.js:35:21)
at Compiler.run (...\node_modules\webpack\lib\Compiler.js:191:24)
at runWithDependencies (...\node_modules\webpack\lib\MultiCompiler.js:239:15)
at asyncLib.map (...\node_modules\webpack\lib\MultiCompiler.js:175:6)
at arrayEachIndex (...\node_modules\neo-async\async.js:2494:9)
at Object.map (...\node_modules\neo-async\async.js:2845:9)
at runCompilers (...\node_modules\webpack\lib\MultiCompiler.js:172:13)
at MultiCompiler.runWithDependencies (...\node_modules\webpack\lib\MultiCompiler.js:184:3)
at MultiCompiler.run (...\node_modules\webpack\lib\MultiCompiler.js:235:9)
at processOptions (...\node_modules\webpack-cli\bin\webpack.js:499:20)
at yargs.parse (...\node_modules\webpack-cli\bin\webpack.js:502:3)
at Object.parse (...\node_modules\yargs\yargs.js:539:18)
at ...\node_modules\webpack-cli\bin\webpack.js:212:8
at Object.<anonymous> (...\node_modules\webpack-cli\bin\webpack.js:504:3)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
script exit code: 1npm ERR! code ELIFECYCLE
解决方案:
yarn upgrade happypack@5.0.0
It seems to work ok.
参考链接:
Incompatible with webpack@4.0.0-alpha.1 (the @next version as of now)