Skip to content

Commit 570658c

Browse files
authored
Fix CLI arg parsing to allow usage with no arguments (#12925)
1 parent fa00680 commit 570658c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changeset/fast-olives-invent.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-router/dev": patch
3+
---
4+
5+
Fix CLI parsing to allow argumentless `npx react-router` usage

packages/react-router-dev/bin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ let arg = require("arg");
55
// default `NODE_ENV` so React loads the proper version in it's CJS entry script.
66
// We have to do this before importing `run.ts` since that is what imports
77
// `react` (indirectly via `react-router`)
8-
let args = arg({}, { argv: process.argv.slice(2), stopAtPositional: true });
9-
if (args._[0] === "dev") {
8+
let args = arg({}, { argv: process.argv.slice(2), permissive: true });
9+
if (args._.length === 0 || args._[0] === "dev") {
1010
process.env.NODE_ENV = process.env.NODE_ENV ?? "development";
1111
} else {
1212
process.env.NODE_ENV = process.env.NODE_ENV ?? "production";

0 commit comments

Comments
 (0)