Skip to content
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

Adding a middleware from CLI does not work #1481

Open
Nermeen-M opened this issue Jan 11, 2024 · 6 comments
Open

Adding a middleware from CLI does not work #1481

Nermeen-M opened this issue Jan 11, 2024 · 6 comments

Comments

@Nermeen-M
Copy link

I'm trying to add a middleware using CLI as follows:
json-server --watch data.json --middlewares api.js

But it doesn't work and this error appears:

TypeError [ERR_PARSE_ARGS_UNKNOWN_OPTION]: Unknown option '--middlewares'. To specify a positional argument starting with a '-', place it at the end of the command after '--', as in '-- "--middlewares"

How to fix this error?

@kvnloughead
Copy link

Hi, I had a similar issue with a different flag, you could try using v0 instead of v1

@Nermeen-M
Copy link
Author

Nermeen-M commented Jan 13, 2024

Update: It is working!
(there were installation conflicts in my case)

@kvnloughead Thank you for your reply but it is still not working with me!

@jspedrovicente
Copy link

@Nermeen-M what were the issues?
I can't get '-m ' to work

@mkamakshi
Copy link

@Nermeen-M how did you resolve this issue?
I am getting the same error now. I am unable to proceed with my json-server-auth set up.

@jspedrovicente
Copy link

@mkamakshi hey, so I did solve the issue, so the thing is that json-server is at version "alpha", so what you need to do is uninstall it and install it at an older version.
the versions I used were:
"json-server": "^0.17.4",
"json-server-auth": "^2.1.0",

cause the version 1.0^ of json-server doesn't have middleware implementations.

@Nermeen-M
Copy link
Author

@mkamakshi uninstall json server then install it again with version 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants