diff --git a/.changeset/fast-olives-invent.md b/.changeset/fast-olives-invent.md new file mode 100644 index 0000000000..a0b696ef1b --- /dev/null +++ b/.changeset/fast-olives-invent.md @@ -0,0 +1,5 @@ +--- +"@react-router/dev": patch +--- + +Fix CLI parsing to allow argumentless `npx react-router` usage diff --git a/packages/react-router-dev/bin.js b/packages/react-router-dev/bin.js index 0373bf96f7..1fd8438f99 100755 --- a/packages/react-router-dev/bin.js +++ b/packages/react-router-dev/bin.js @@ -5,8 +5,8 @@ let arg = require("arg"); // default `NODE_ENV` so React loads the proper version in it's CJS entry script. // We have to do this before importing `run.ts` since that is what imports // `react` (indirectly via `react-router`) -let args = arg({}, { argv: process.argv.slice(2), stopAtPositional: true }); -if (args._[0] === "dev") { +let args = arg({}, { argv: process.argv.slice(2), permissive: true }); +if (args._.length === 0 || args._[0] === "dev") { process.env.NODE_ENV = process.env.NODE_ENV ?? "development"; } else { process.env.NODE_ENV = process.env.NODE_ENV ?? "production";