Repository navigation
Description
Summary
A non-empty target directory is the most common reason a create-prisma run ends without a project. In the last 28 days of CLI telemetry, failure-reason: target_directory_not_empty accounts for about 28% of all failed runs, ahead of dependency install failures and unsupported Node versions.
The only guidance the CLI gives is to overwrite:
$ cd existing-app && npm create prisma@latest .
┌ ◭ Create Prisma 8
└ Target directory . is not empty. Use --force to continue.
([email protected], Node 24, macOS. Same message in --json mode under error.message.)
Why it matters
Three different people hit this message, and it only fits one of them.
- Someone adding Prisma to an app they already have. They run
create-prismain the app folder or with.. For them--forceis the wrong advice: it scaffolds a starter over their files and replaces any Prisma config, contract and database-client files. The right path isprisma orm init, which the CLI never mentions. - Someone retrying after a failed run. Install or deploy failed, the directory was left behind, and they rerun the same command.
--forceis the right answer here, and it is the case the message was written for. - Someone who picked a name that is already taken. They want a fresh project and only need a different name.
Interactive runs get the worst version of it. The directory is only checked after the template prompt, so people answer two questions and are then dropped back to the shell instead of being asked for another name.
We cannot tell the three groups apart today. The failure is raised before the create context exists, so target-directory-state is null on every one of these events. That makes it hard to decide how much to invest in a real "add to existing project" path.
Proposal
- Say what to do for each case. Look at what is in the directory (a
package.json, aprisma.config.ts, or neither) and lead with the matching next step:prisma orm initfor an existing app, the Prisma CLI or--forcefor an existing Prisma project, a different name otherwise. - Ask again in interactive runs. Check the directory right after the name prompt, before the template prompt, and re-prompt for the name instead of exiting.
- Record what kind of directory it was. Add a coarse
target-directory-kindvalue to the failure event (no names, no paths) so the split between the three groups is visible.
Follow-ups
- Decide, from the data in (3), whether
create-prismashould offer to runprisma orm initin place for existing apps instead of only pointing at it. https://www.prisma.io/docs/prisma-orm/add-to-existing-projectreturns 404 (only the per-database pages exist), so there is no single page to link for this path.
Activity