Skip to content

fix(create-app): detect the running package manager via getUserAgent - #2720

Open
SouichiroTsujimoto wants to merge 1 commit into
slidevjs:mainfrom
SouichiroTsujimoto:fix/create-app-package-manager-name
Open

fix(create-app): detect the running package manager via getUserAgent#2720
SouichiroTsujimoto wants to merge 1 commit into
slidevjs:mainfrom
SouichiroTsujimoto:fix/create-app-package-manager-name

Conversation

@SouichiroTsujimoto

@SouichiroTsujimoto SouichiroTsujimoto commented Aug 26, 2026

Copy link
Copy Markdown

Summary

create-slidev currently stringifies the package manager as [object Object], then crashes with ERR_INVALID_ARG_TYPE if you choose to install immediately.

This restores getUserAgent() (the package manager that is running create-slidev) instead of detect() (lockfile lookup up the directory tree). If nothing is detected, it still falls back to npm, which is the #2703 fix for null install when the script is run with plain Node.

Background

On current create-slidev (v52.19.1), scaffolding succeeds but the follow-up install crashes:

❯ bun create slidev

  ●■▲
  Slidev Creator  v52.19.1

✔ Project name: … slidev-sample
  Scaffolding project in slidev-sample ...
  Done.

✔ Install and start it now using [object Object]? … yes
TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received an instance of Object
    at normalizeSpawnArguments (node:child_process:539:3)
    at spawn (node:child_process:746:13)
    at ExecProcess.spawn (.../tinyexec/dist/main.mjs:321:18)
    at x (.../tinyexec/dist/main.mjs:404:7)
    at init (.../create-slidev/index.mjs:116:11)
    {
      code: 'ERR_INVALID_ARG_TYPE'
    }

The prompt shows [object Object]. Answering yes spawns that object as the command. Answering no prints [object Object] install / [object Object] run dev. The template is already written, so a manual bun install still works.

#2703 was meant to fix the case where running create-slidev directly with Node detects no package manager, so the later-install hints became null install / null run dev. The author, following review, used:

const pkgManager = getUserAgent() ?? 'npm'

antfu suggested that same line. A later chore: update on the PR swapped it to detect() and then used the return value as a command name. There is no note that detection should switch to lockfiles.

That produced:

  • using [object Object]? in the prompt
  • a crash on yes, because tinyexec tries to spawn an object
  • detection of the lockfile in cwd / parents, instead of the package manager that launched create-slidev

The intent recorded in #2516 was to detect the package manager running create-slidev.

Change

packages/create-app/index.mjs only:

const pkgManager = getUserAgent() ?? 'npm'

Test plan

Verified locally:

  • bun run create-slidev (or bun create slidev) shows using bun? and does not throw if you answer yes
  • pnpm create slidev / npm init slidev show pnpm / npm respectively
  • node packages/create-app/index.mjs with no user agent shows using npm? (fix(create-app): default manual setup to npm #2703 fallback)
  • Answering no writes the real package manager name into the hints and README, not [object Object]

detect() returns an object and was used as a command name, so create-slidev
printed [object Object] and crashed on install. Restore getUserAgent() with
an npm fallback, matching the reviewed version of slidevjs#2703.

Co-authored-by: Cursor <cursoragent@cursor.com>
@netlify

netlify Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 2dd05d5
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/6a8e62b45af9fd0008d431c1
😎 Deploy Preview https://deploy-preview-2720--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

1 participant