happypack
happypack copied to clipboard
TypeError: Cannot read property 'profile' of undefined
Hi, I am a new user of happypack. When I add happypack to my project, it report the flowing error. I don't understand what's wrong with my configuration.
TypeError: Cannot read property 'profile' of undefined
at isVerbose (C:\Users\lenovo\Desktop\frontend-vue\node_modules\happypack\lib\HappyPlugin.js:242:23)
at HappyPlugin.apply (C:\Users\lenovo\Desktop\frontend-vue\node_modules\happypack\lib\HappyPlugin.js:72:24)
at Resolver.apply (C:\Users\lenovo\Desktop\frontend-vue\node_modules\tapable\lib\Tapable.js:375:16)
at C:\Users\lenovo\Desktop\frontend-vue\node_modules\enhanced-resolve\lib\ResolverFactory.js:249:12
at Array.forEach (<anonymous>)
at Object.exports.createResolver (C:\Users\lenovo\Desktop\frontend-vue\node_modules\enhanced-resolve\lib\ResolverFactory.js:248:10)
at WebpackOptionsApply.process (C:\Users\lenovo\Desktop\frontend-vue\node_modules\webpack\lib\WebpackOptionsApply.js:283:47)
at webpack (C:\Users\lenovo\Desktop\frontend-vue\node_modules\webpack\lib\webpack.js:37:48)
at startDevServer (C:\Users\lenovo\Desktop\frontend-vue\node_modules\webpack-dev-server\bin\webpack-dev-server.js:367:16)
at processOptions (C:\Users\lenovo\Desktop\frontend-vue\node_modules\webpack-dev-server\bin\webpack-dev-server.js:350:5)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
at Function.Module.runMain (module.js:678:11)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
Here is my configuration:
new HappyPack({
id: 'happybabel',
loaders: [
{
loader: 'babel-loader',
options: {
// babelrc: path.resolve(__dirname, '.babelrc'),
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
}
}
],
verbose: false,
debug: true
})
{
test: /\.js$/,
use: 'happypack/loader?id=happybabel'
},
Hello! Thanks for reporting and sorry you're having trouble. What webpack version is this?
3.10.0
I'm also encountering this exact issue. Looking at the code, the resolver
that is provided to HappyPlugin.prototype.apply
does not have options
. Looks like the resolver
is the enhanced-resolve
's Resolver
and is created in enhanced-resolve/lib/ResolverFactory:106
.
Running webpack 4.16.1, ts-loader 4.4.2.
Also have fork-ts-checker-webpack-plugin 0.4.3 and tsconfig-paths-webpack-plugin 3.2.0.
Seems like a simple fix (same for isDebug
as well), from:
function isVerbose(compiler, plugin) {
return plugin.config.verbose && (
!compiler.options.profile ||
plugin.config.verboseWhenProfiling
);
};
to:
function isVerbose(compiler, plugin) {
return plugin.config.verbose && (
!(compiler.options && compiler.options.profile) ||
plugin.config.verboseWhenProfiling
);
};
never mind - figured out the issue: I had placed the plugins under resolvers
and not the top-level plugins
😞. @maybeeee This might also be your issue too, if you hadn't figured that out by now.
Thanks for leaving the fix @rue-bwebb , this helped me out significantly 🙌