Skip to content

fix(create-vite): fix "too many arguments error" when using TanStack Router template with pnpm#21648

Open
Natejsx wants to merge 3 commits intovitejs:mainfrom
Natejsx:fix-pnpm-dlx-normalization
Open

fix(create-vite): fix "too many arguments error" when using TanStack Router template with pnpm#21648
Natejsx wants to merge 3 commits intovitejs:mainfrom
Natejsx:fix-pnpm-dlx-normalization

Conversation

@Natejsx
Copy link

@Natejsx Natejsx commented Feb 16, 2026

When running pnpm create vite@latest and selecting the TanStack Router variant, the generated command uses an npm-style -- separator which pnpm dlx does not require. Keeping the separator causes args to be interpreted as extra positional arguments, resulting in:

error: too many arguments for 'create'. Expected 1 argument but got 4.

This PR normalizes the pnpm path by removing the npm-only separator so the TanStack Router flow works correctly with pnpm.

Fixes #21618. fixes #21614


  • For pkgManager === 'pnpm', normalize the custom command string so:
    • pnpm dlx <pkg> -- <args> becomes pnpm dlx <pkg> <args>
  • Refactored the pnpm handling to live inside the existing .replace(/^npm exec /, ...) flow (matching the pattern used by npm create), per reviewer suggestion.

  • Leaving the -- separator in place and trying to special-case downstream args parsing.
    • Rejected because -- is npm-specific here and causes pnpm to pass arguments differently.

I wasn't able to run an end-to-end reproduction of the TanStack Router flow due to TanStack/cli#364, but local checks/build pass and the fix is isolated to command normalization.

If there’s a preferred test location/approach for validating the generated command string, I’m happy to add it.

@Natejsx
Copy link
Author

Natejsx commented Feb 17, 2026

is my changes able to be merged?

Comment on lines 914 to 919
.replace(
/^pnpm dlx (\S+) -- /,
// `npm exec <pkg> -- <args>` uses `--` to split npm flags from package args.
// `pnpm dlx` doesn't need this separator, and keeping it can break CLIs.
'pnpm dlx $1 ',
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you do this in the replace callback above?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(you don't need to create a new PR for each changes)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I can implement this in the replace callback!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed the changes you asked, and got 3 neutral, 2 skipped, and 14 successful checks

Copy link
Member

@sapphi-red sapphi-red Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find the changes

@Natejsx Natejsx force-pushed the fix-pnpm-dlx-normalization branch from 160ca28 to 4762396 Compare February 17, 2026 05:02
@bluwy bluwy changed the title fix(create-vite): Supersedes: #21618 (same issue, updated implementation per review feedback). fix(create-vite): fix "too many arguments error" when using TanStack Router template with pnpm Feb 24, 2026
@bluwy
Copy link
Member

bluwy commented Feb 24, 2026

Could we remove the -- in the npm exec commands instead so we don't have to do the replacements afterwards? Or we add the -- consistently in all npm exec commands. The npm docs seems to recommend specifying npm exec --: https://docs.npmjs.com/cli/v11/commands/npm-exec#npx-vs-npm-exec

@sapphi-red
Copy link
Member

Without the --, the flags will be passed to npm instead of the template generators, so we need to have them.

$ npm exec @tanstack/cli@latest create TARGET_DIR --template file-router --interactive
npm warn "file-router" is being parsed as a normal command line argument.
npm warn Unknown cli config "--template". This will stop working in the next major version of npm.
npm warn Unknown cli config "--interactive". This will stop working in the next major version of npm.

@bluwy
Copy link
Member

bluwy commented Feb 25, 2026

Ah so it seems like we need the -- as long as there'a any --flags, some of the existing npm exec doesn't have -- and works because they don't have flags. I guess we should use npm exec -- everywhere then and update the regex and handle accordingly:

.replace(/^npm exec /, () => {

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

Successfully merging this pull request may close these issues.

Error when creating Vite React app with TanStack Router using pnpm

3 participants