json-server
json-server copied to clipboard
Adding a middleware from CLI does not work
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?
Hi, I had a similar issue with a different flag, you could try using v0 instead of v1
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!
@Nermeen-M what were the issues? I can't get '-m ' to work
@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.
@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.
@mkamakshi uninstall json server then install it again with version 0