webpack-cli: [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] error when using `--watch` flag
Describe the bug
PR with the configuration https://github.com/javascript-obfuscator/javascript-obfuscator/pull/776
After upgrade from webpack@4 to webpack@5 and webpack-cli@3 to webpack-cli@4.0.0 I got the following error:
[DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
This error happens only when using --watch
flag:
webpack --config ./webpack/webpack.node.config.js --mode development --watch
Full error trace:
(node:62890) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
at webpack (/Users/sanex/WebstormProjects/javascript-obfuscator/node_modules/webpack/lib/webpack.js:145:5)
at f (/Users/sanex/WebstormProjects/javascript-obfuscator/node_modules/webpack/lib/index.js:35:15)
at Compiler.createCompiler (/Users/sanex/WebstormProjects/javascript-obfuscator/node_modules/webpack-cli/lib/utils/Compiler.js:129:35)
at WebpackCLI.run (/Users/sanex/WebstormProjects/javascript-obfuscator/node_modules/webpack-cli/lib/webpack-cli.js:220:32)
at async runCLI (/Users/sanex/WebstormProjects/javascript-obfuscator/node_modules/webpack-cli/lib/bootstrap.js:74:24)
Expected behavior
No error.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 75
- Comments: 43 (24 by maintainers)
Fixed in
webpack-cli@4.2.0
, if somebody faced with the problem again, please open a new issue with reproducible test repo, because we tests most of cases 😄I will fix it 👍
Release will be today
@snitin315 No, will be fixed in the near future, the next PR
I did update to
"webpack": "^5.3.2"
and the error still appearsI get the same error, but I think it’s worth mentioning that the watch mode does actually work. Yes, it throws that warning at the start, but it still bundles and still watches for changes correctly.
Same problem for me when trying to upgrade to
webpack@5.1.3
andwebpack-cli@4.0.0
Some problems on webpack side with new API, we are working on it, so I will do release with other fixes, but it will be fixed tomorrow with patch release
Running latest webpack 5.22 and webpack-cli 4.5 - No errors !
Just note, this is unnecessary using
--watch
andwatch: true
together, just removewatch: true
from the configI still have this problem!
“webpack”: “^5.10.3”, “webpack-cli”: “^4.2.0”, “webpack-dev-server”: “^3.11.0”
node: v14.15.0 npm: 6.14.8 mac: 10.14.6
github
You need update
webpack-cli
to the latest stable version“webpack”: “^5.61.0” getting same warning when I set the watch property value to
true
in the config file and running this code:if I set to
false
the watch property value in config so the warning is gone. Anyway, this warning I guess is harmless so it’s not big deal.Had a quick look and removing
watch: true
from config will not help as--watch
is still propagated to optionshttps://github.com/webpack/webpack/blob/master/lib/webpack.js#L140
Looks like we would need to refactor how the webpack-cli handles complier ( have some wip already but would require https://github.com/webpack/webpack/pull/11784 )
I have this with this project https://github.com/styled-components/vscode-styled-components/blob/master/package.json and we don’t have
watch: true
set. Looks like 4.1.0 is out so we will try that@gimmi why need to spam it? I’ve always tried to figure it out, but I can’t, can you explain it to me?
We have two problems here:
watch
option from config