[BUG] Installation when selecting Prisma fails
Describe the bug
When using Prisma as the ORM for the database on installation, it fails citing an unknown command "npx prisma init".
To Reproduce
In an empty directory, run the installation command npx -p @tsed/cli tsed init . and during the prompts, select Database as a required component and choose Prisma as the ORM manager for the database.
Installation will appear to proceed, producing the package.json file as well as beginning to install the NPM packages and create default files.
Eventually the installation will attempt to run npx prisma init which causes the rest of the installation to fail.
This occurs irrespective of what platform you choose (Express/Koa). No issues occur when you choose TypeORM.
Expected behavior
Installation should be successful and Prisma should be installed correctly alongside everything else.
Code snippets
? Choose the target Framework: Koa.js
? Choose the architecture for your project: Ts.ED
? Choose the convention file styling: Ts.ED
? Check the features needed for your project Database, Documentation, Testing, Linter
? Choose a documentation plugin Swagger
? Choose a ORM manager Prisma
? Choose unit framework Vitest
? Choose linter tools framework EsLint
? Choose extra linter tools Prettier, Lint on commit
? Choose the runtime: Node.js + SWC
? Choose the package manager: NPM
↓ Write RC files
✔ Initialize package.json
✔ Install plugins
↓ Write RC files
✔ Initialize package.json
✔ Install plugins
✔ Load plugins
✔ Install plugins dependencies
✔ Generate project files
✖ Command failed with exit code 127: npx prisma init
sh: 1: prisma: not found
◼ Add Ts.ED configuration to Prisma schema
◼ Generate files for eslint
◼ Add dependencies
◼ Generate files for vitest
◼ Install dependencies
◼ Add husky prepare task
◼ Run linter
◼ Generate barrels files
Error: Command failed with exit code 127: npx prisma init
sh: 1: prisma: not found
at makeError (file:///home/thomas/.npm/_npx/8fd6f229e097057e/node_modules/execa/lib/error.js:60:11)
at handlePromise (file:///home/thomas/.npm/_npx/8fd6f229e097057e/node_modules/execa/index.js:124:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
name: 'CLI_ERROR',
cli: Cli {
injector: InjectorService(54) [Map] {
[class CliConfiguration extends DIConfiguration] => [Provider],
[class ProjectPackageJson] => [Provider],
[class CliFs] => [Provider],
[class CliCore] => [Provider],
[Function: Configuration] => [Provider],
Symbol(LOGGER) => [Provider],
[class Logger] => [Provider],
[Function: CliPackageJson] => [Provider],
[class CliExeca] => [Provider],
[class BunManager extends BaseManager] => [Provider],
[class NpmManager extends BaseManager] => [Provider],
[class PNpmManager extends BaseManager] => [Provider],
[class CliYaml] => [Provider],
[class YarnBerryManager extends BaseManager] => [Provider],
[class YarnManager extends BaseManager] => [Provider],
[class PackageManagersModule] => [Provider],
[class CliHooks] => [Provider],
[class CliService] => [Provider],
[class CliDockerComposeYaml] => [Provider],
[class CliProxyAgent] => [Provider],
[class CliHttpClient extends CliHttpLogClient] => [Provider],
[class CliLoadFile] => [Provider],
[class NpmRegistryClient] => [Provider],
[class CliPlugins] => [Provider],
[class CliRunScript] => [Provider],
[class RootRendererService extends Renderer] => [Provider],
[class SrcRendererService extends Renderer] => [Provider],
[class ScriptsRendererService extends Renderer] => [Provider],
[class AddCmd] => [Provider],
[class ProvidersInfoService] => [Provider],
[class ClassNamePipe] => [Provider],
[class OutputFilePathPipe] => [Provider],
[class RoutePipe] => [Provider],
[class GenerateCmd] => [Provider],
[class InitExpressPlatform] => [Provider],
[class InitKoaPlatform] => [Provider],
[class InitPlatformsModule] => [Provider],
[class NodeRuntime extends BaseRuntime] => [Provider],
[class BabelRuntime extends NodeRuntime] => [Provider],
[class BunRuntime extends BaseRuntime] => [Provider],
[class WebpackRuntime extends BabelRuntime] => [Provider],
[class RuntimesModule] => [Provider],
[class InitCmd] => [Provider],
[class RunCmd] => [Provider],
[class UpdateCmd] => [Provider],
[class CliPrisma] => [Provider],
[class PrismaCmd] => [Provider],
[class PrismaInitHook] => [Provider],
[class CliPluginPrismaModule] => [Provider],
[class EslintInitHook] => [Provider],
[class CliPluginEslintModule] => [Provider],
[class VitestGenerateHook] => [Provider],
[class VitestInitHook] => [Provider],
[class CliPluginVitestModule] => [Provider],
logger: [Logger],
resolvedConfiguration: true
},
cliService: CliService {
reinstallAfterRun: true,
program: [Command],
pkg: [Object],
hooks: CliHooks {},
projectPkg: [ProjectPackageJson],
packageManagers: [PackageManagersModule],
commands: [Map]
}
},
origin: Error: Command failed with exit code 127: npx prisma init
sh: 1: prisma: not found
at makeError (file:///home/thomas/.npm/_npx/8fd6f229e097057e/node_modules/execa/lib/error.js:60:11)
at handlePromise (file:///home/thomas/.npm/_npx/8fd6f229e097057e/node_modules/execa/index.js:124:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
shortMessage: 'Command failed with exit code 127: npx prisma init',
command: 'npx prisma init',
escapedCommand: 'npx prisma init',
exitCode: 127,
signal: undefined,
signalDescription: undefined,
stdout: '',
stderr: 'sh: 1: prisma: not found',
cwd: '/home/thomas/GitHub/okie-api',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
}
Repository URL example
No response
OS
Ubuntu
Node version
20.12.2
Library version
8.3.2
Additional context
No response
Looking at the package.json, it appears that Prisma never actually gets installed. Below is the default package.json created by running the installation command.
{
"name": "okie-api",
"version": "1.0.0",
"description": "",
"scripts": {
"build": "npm run barrels && swc src --out-dir dist -s --strip-leading-paths",
"barrels": "barrels",
"start": "npm run barrels && nodemon src/index.ts",
"start:prod": "cross-env NODE_ENV=production node --import @swc-node/register/esm-register src/index.js",
"test": "npm run test:lint && npm run test:coverage",
"test:unit": "cross-env NODE_ENV=test vitest run",
"test:watch": "cross-env NODE_ENV=test vitest",
"test:coverage": "cross-env NODE_ENV=test vitest run --coverage"
},
"dependencies": {
"@koa/cors": "^5.0.0",
"@koa/router": "^13.1.0",
"@swc-node/register": "^1.10.9",
"@swc/cli": "^0.5.2",
"@swc/core": "^1.10.1",
"@swc/helpers": "^0.5.15",
"@tsed/ajv": "^8.3.2",
"@tsed/barrels": "^6.1.3",
"@tsed/core": "^8.3.2",
"@tsed/di": "^8.3.2",
"@tsed/engines": "^8.3.2",
"@tsed/exceptions": "^8.3.2",
"@tsed/json-mapper": "^8.3.2",
"@tsed/logger": "^7.0.1",
"@tsed/openspec": "^8.3.2",
"@tsed/platform-cache": "^8.3.2",
"@tsed/platform-exceptions": "^8.3.2",
"@tsed/platform-http": "^8.3.2",
"@tsed/platform-koa": "^8.3.2",
"@tsed/platform-log-request": "^8.3.2",
"@tsed/platform-middlewares": "^8.3.2",
"@tsed/platform-params": "^8.3.2",
"@tsed/platform-response-filter": "^8.3.2",
"@tsed/platform-views": "^8.3.2",
"@tsed/schema": "^8.3.2",
"@tsed/swagger": "^8.3.2",
"@tsed/typegraphql": "^8.3.2",
"ajv": "^8.17.1",
"apollo-datasource": "^3.3.2",
"apollo-datasource-rest": "^3.7.0",
"apollo-server-core": "^3.13.0",
"apollo-server-koa": "2.25.2",
"class-validator": "^0.13.2",
"cross-env": "^7.0.3",
"dotenv": "^16.4.7",
"dotenv-expand": "^12.0.1",
"dotenv-flow": "^4.1.0",
"graphql": "^15.9.0",
"koa": "^2.15.3",
"koa-bodyparser": "^4.4.1",
"koa-compress": "^5.1.1",
"koa-override": "^4.0.0",
"koa-qs": "^3.0.0",
"type-graphql": "^1.1.1",
"typescript": "^5.7.2"
},
"devDependencies": {
"@tsed/cli-plugin-eslint": "6.1.3",
"@tsed/cli-plugin-prisma": "6.1.3",
"@tsed/cli-plugin-typegraphql": "6.1.3",
"@tsed/cli-plugin-vitest": "6.1.3",
"@types/koa": "^2.15.0",
"@types/koa__cors": "^5.0.0",
"@types/koa__router": "^12.0.4",
"@types/koa-bodyparser": "^4.3.12",
"@types/koa-compress": "^4.0.6",
"@types/koa-json": "^2.0.23",
"@types/koa-qs": "^2.0.3",
"@types/koa-send": "^4.1.6",
"@types/multer": "^1.4.12",
"@types/node": "^22.10.1",
"@types/supertest": "^6.0.2",
"@types/validator": "^13.12.2",
"@vitest/coverage-v8": "^2.1.8",
"apollo-server-testing": "^2.25.3",
"nodemon": "^3.1.7",
"supertest": "^7.0.0",
"tslib": "^2.8.1",
"unplugin-swc": "^1.5.1",
"vitest": "^2.1.8"
},
"tsed": {
"convention": "conv_default",
"architecture": "arc_default",
"packageManager": "npm",
"runtime": "node"
},
"type": "module"
}
Update: by installing the CLI globally (npm install -g @tsed/cli) and running tsed init . directly, rather than through NPX, it now works and installs Prisma as expected.
fixed with v6.1.17