-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 BUG: wrangler pages dev -- npm run serve
gives an "Unknown argument" error
#965
Comments
I just tried this and could not reproduce the error. Steps I took: (Windows 10 - PowerShell
|
Can you provide a runnable example of the problem? |
Can confirm this is a bug since I am also having the same issue. Using [email protected] and:
I have this problem when I try to run the command just after cloning this project (so you can try by yourself): https://github.com/Flotss/maxouxax.me |
I just tried starting wrangler with npx, and the command works just fine when doing so. |
The behavior is very strange since I just tried to run the command with and without npx, and both commands failed. |
👉 Here is a complete reproduction video from scratch, including PowerShell, npm and NodeJS versions wrangler_issue.mp4 |
Hi @MAXOUXAX - thanks for these reproduction steps. I am finally able to get the same problem and I think I have a workaround. The problem is that yargs is only looking for a single positional argument after the |
I think I also have a fix which is very simple: needs to change to: "dev [directory] [-- command..]", telling Yargs that |
On Windows, the following command `wrangler pages dev -- foo bar` would error saying that `bar` was not a known argument. This is because `foo` and `bar` are passed to Yargs as separate arguments. A workaround is to put the command in quotes: `wrangler pages dev -- "foo bar"`. But this fix makes the `command` argument variadic, which also solves the problem. Fixes [cloudflare#965](cloudflare#965)
Glad you successfully reproduced the bug! Although I never built a CLI and therefore never used yargs, the bug only happens in PowerShell, the command works just fine in other prompts, which would mean that yargs behaves differently between prompts, which is pretty odd, and looks like a bug to me. Just to be sure I got that right, it's not an issue coming from wrangler, but an non-intended behavior coming from yargs, which needs to be fixed, right? Thanks for the workaround though, will use this for now! |
I am not sure why the behaviour is different between command prompts. I guess different prompts pass the args in in different ways at the OS level?? Anyway, my PR (#1057) should be a reliable fix across all, and is arguably the right way to do this anyway. |
On Windows, the following command `wrangler pages dev -- foo bar` would error saying that `bar` was not a known argument. This is because `foo` and `bar` are passed to Yargs as separate arguments. A workaround is to put the command in quotes: `wrangler pages dev -- "foo bar"`. But this fix makes the `command` argument variadic, which also solves the problem. Fixes [cloudflare#965](cloudflare#965)
On Windows, the following command `wrangler pages dev -- foo bar` would error saying that `bar` was not a known argument. This is because `foo` and `bar` are passed to Yargs as separate arguments. A workaround is to put the command in quotes: `wrangler pages dev -- "foo bar"`. But this fix makes the `command` argument variadic, which also solves the problem. Fixes [#965](#965)
I think the issue needs to be reopened, because the command What happens is that it doesn't execute the command passed as a parameter, so it opens a web server that tries to proxy requests on port 8080, but fails completely because there's no web server on that port, since the given command hasn't been executed. EDIT: I thought the command was broken for all prompts, but it actually works in all prompts except PowerShell. So the problem is simply not solved. |
Can you try with wrangler 2.0.6, does the problem persist? |
Oops, didn't mention I, of course, upgraded to [email protected]! |
Let me try this again... |
OK so the problem is that the yargs definition is |
So here is the problem... In Windows Powershell when I use
In Windows Command Prompt when I use
Spot the difference? This seems to be something related to
where console.log(process.argv); Then I do see the |
I think we might need to record this as a known issue in Pages + Powershell? |
I just want to mention that even this solution doesn't work anymore since [email protected], so my current solution is to run the npm run serve command separately after running the wrangler command. |
I think this is the best workaround for now. @MAXOUXAX - did the original workaround (to use quotes) actually work with 2.0.5? I believe it would not have, since even with out the fix in 2.0.6 it would still have the same problem. |
Haven't tested the workaround in previous versions so cannot really tell |
Unassigning me for the time being so the Pages team can make a call on what to do next. |
Just tried this behaviour on wrangler 2.0.24, and I am unable to reproduce. Are you still experiencing it? This may also be due to my more up to date powershell version. Get-Host | Select-Object Version
Version
-------
7.1.5 |
@MAXOUXAX The Pages team does not plan to support this sort of command-chaining in Powershell in the near future. As such, we are closing this issue. |
Alright, just a few things then:
|
This doesn't seem to be too much to ask for. One command below works and the other doesn't. It seems like a fix would be possible. Otherwise this need to be clearly spelt out in the documentation. Works
Fails
|
@nneil - what version of wrangler do you have installed globally? Try running: npx wrangler --version
wrangler --version The difference between the two commands you used is that the first will use the locally installed version and the second will use the global one. We do not recommend using a globally installed one; instead you should install wrangler local to your project and then use |
@petebacondarwin That's a good point, but I should have been clearer. I install nothing as a global: I would much rather waste some disk space and have precise control over my versions. I just put
|
Ah, right. This is an issue with how Powershell works, not the version of Wrangler that you are running. This is a known issue on a Pages command that we have deprecated. I think it would be nice to try to tell if you are trying to do this in PowerShell and add a warning. I'll open an issue to add that. Otherwise, there is no plan to make this work. |
What version of
Wrangler
are you using?2.0.2
What operating system are you using?
Windows
Describe the Bug
I am currently giving WebStorm a try and I am encountering a problem when running the command below:
wrangler pages dev --proxy 8080 -- npm run serve
Indeed, when this command is executed via a classic Command Prompt, everything works fine, but when it is executed from PowerShell, the following error is displayed:
The command
npm run serve
works correctly.The text was updated successfully, but these errors were encountered: