webpack-cli: error: option '--open ' argument missing
As per the request here https://github.com/webpack/webpack.js.org/pull/4099#issuecomment-718825131.
Describe the bug
webpack serve --open
throws an error:
error: option '--open <value>' argument missing
What is the current behavior?
To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/chenxsan/webpack-demo
git checkout 8ffd9d229ce344fb4b595e4045aee7b074be16cc
npm install
npm start
Expected behavior
Screenshots
Please paste the results of webpack-cli info
here, and mention other relevant information
Additional context
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 24
- Comments: 32 (10 by maintainers)
I had the same issue, but adding the
open: true
in thedevServer
block ofwebpack.config.js
, seems to work for me.I was following the tutorial from the official website.
This
--open
argument bug happened before and there are some stack overflow questions and GitHub issues of the same bug.If you just like me, trying to learn Webpack and don’t care, providing the url allows you to continue:
webpack serve --open Chrome.exe
Providing a url like @zero41120 said didn’t work for me. But,
webpack serve --open 'Google Chrome'
works. ReplaceGoogle Chrome
with your browser name.@cannandev @snitin315 Yes. Looks like the --open just opens whatever you provide, for example
webpack serve --open notepad.exe
I think it worked for me because that I’m on windows environment, and it knows that http uses my default browser. I will update my original comment.
This will be fixed with
webpack-dev-server
version 4. https://github.com/webpack/webpack-dev-server/blob/9f1d02b909e22ece60dde2e57cbfce14feafde69/bin/cli-flags.js#L47remove
--open
from"start": "webpack serve --open"
and add that into yourwebpack.config.js
:in this case, that opens your default browser
Had the same problem, fixed it by just using
webpack serve
without--open
or a browser value. I’d then have to open the browser and go to the localhost serverhttp://localhost:8080/
En realidad si, lo puedes lograr así. Solo que cambio la forma explicita como estaba definida la sintaxis.
"dev-server": "webpack serve --open chrome"
This works for me, on a windows 10 machine with NodeJs 15 and webpack 5
webpack serve --open chrome
will fix the issueYes,
string
functionality (webpack --open 'browser-name'
) works fine.