Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I'm running on windows 10. I used to be able to supply command-line parameters for rewrite rules but today I ran into problems.

Windows is interpreting the ">" character in the rewrite rule as being the option to redirect output to a separate file, like you would here:

dir > files.txt

The most basic case that shows this is:

npx ws -r "/a -> /b"

The response I get is "Access is denied." which is Windows complaining about trying to write to /b.

There doesn't seem to be a way to escape the > character, so I've opted to use a lws.config.js config file instead, which solves the problem.

I'd suggest adding something about this to your wiki, as the Rewrite tutorial only mentions Windows needing double quotes instead of single quotes while in my case none of the inline examples work. It'd help others avoid the troubleshooting I had to go through.

Otherwise, I think your module is really useful. Thanks for making it!

You must be logged in to vote

Replies: 10 comments

Comment options

Hi, can you confirm which shell you are using? I just ran the following command in both Git Bash and cmd on Windows 10 - everything worked correctly, as expected..

$ ws -r "/here -> /there" --verbose
{ 'middleware.cors.config': {} }
{
  'middleware.rewrite.config': { rewrite: [ { from: '/here', to: '/there' } ] }
}
{ 'middleware.conditional-get.config': {} }
{
  'middleware.static.config': { hidden: true, root: 'z:\\' }
}
{ 'middleware.index.config': { icons: true } }
You must be logged in to vote
0 replies
Comment options

I think I was using crd.exe, although I likely used the default shell in vs code as well.

I noticed you’re not running it via npx. Could that be why it works for you?

You must be logged in to vote
0 replies
Comment options

It could be an issue with npx or other Windows shells, then..

If you're having npx issues, this should work as an alternative:

./node_modules/.bin/ws -r "/here -> /there" --verbose

Closing, as the issue is not with local-web-server itself..

You must be logged in to vote
0 replies
Comment options

I had the same issue on Windows, but fixed it with the workaround @75lb suggested. (although I needed to use backslashes rather than forward slashes)

Example:

.\node_modules\.bin\ws -r "/here -> /there" --verbose

So it appears the npx utility is not correctly handling either the quotes or the arrow. May be worth linking to this thread in the readme, for Windows users.

You must be logged in to vote
0 replies
Comment options

Could you confirm which version of npm you are using? I think this npx issue may have been fixed by this npm v7.4.0 PR..

You must be logged in to vote
0 replies
Comment options

Ah, I am using NPM v6.14.5; the PR does look like it might fix it.

Unfortunately I don't have the motivation to confirm that at this point. (I don't want to risk ruining something in my npm dependency trees)

Because I can't confirm the issue for the latest versions (and because the linked PR probably fixes it), I'm fine with this issue being reclosed unless/until someone else can confirm it's still present in NPM v7.4.0+. (since there's a workaround for now anyway)

You must be logged in to vote
0 replies
Comment options

Despite the fault apparently being with npx, I still think it's worth considering updating the documentation to either mention the workaround or a minimum supported version in Windows. For me, I'm happy enough to use the separate config file. I think it's more maintainable in my case anyway.

Thanks for your help.

You must be logged in to vote
0 replies
Comment options

@kenlyon can you confirm this is still an issue with the lastest npm? As i posted above, this issue was apparently fixed in npm v7.4.0..

You must be logged in to vote
0 replies
Comment options

@75lb I can confirm that it does indeed work. Based on the Previous Releases page for node/npm, I confirmed it was still an issue with node 15.51.1 / npm 7.3.0. However, the next release (node 15.6.0 / npm 7.4.0) worked fine.

It's not really a viable solution for my use case, though, because we're using the LTS version and it wouldn't be trivial to switch to the "Current" track at this time. As I mentioned above, I'm fine with using the separate config file.

In addition, I confirmed it's still a problem in the latest LTS version. (node 14.17.0 / npm 6.14.13)

You must be logged in to vote
0 replies
Comment options

@kenlyon ok, thanks for confirming.. I have added a note to the top of the rewrite tutorial as suggested and will leave this issue open for a while. 👍

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants
Converted from issue

This discussion was converted from issue #158 on July 08, 2021 18:02.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.