I am trying to marry Ts.Ed v7.35 and prisma v5.2 following this official tutorial.
After running npm install
I get this error while executing npx prisma generate
:
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: Generator "@tsed/prisma" failed:
/bin/sh: 1: @tsed/prisma: not found
Those are the files inside ./node_modules/@tsed/prisma/:
$> ls -lah ./node_modules/@tsed/prisma/
drwxrwxr-x 5 dev dev 4.0K Sep 11 20:35 lib/
drwxrwxr-x 3 dev dev 4.0K Sep 11 20:35 node_modules/
drwxrwxr-x 2 dev dev 4.0K Sep 11 20:35 scripts/
-rw-rw-r-- 1 dev dev 135 Sep 11 20:35 .eslintignore
-rw-rw-r-- 1 dev dev 50 Sep 11 20:35 .eslintrc.js
-rw-rw-r-- 1 dev dev 2.1K Sep 11 20:35 package.json
-rw-rw-r-- 1 dev dev 9.6K Sep 11 20:35 readme.md
-rw-rw-r-- 1 dev dev 754 Sep 11 20:35 tsconfig.esm.json
Thusly, the package is obviously installed. I hope somebody might see what I am missing... Great htanks to you all. <3
Project structure:
drwxrwxr-x 335 dev dev 12K Sep 11 21:19 node_modules/
drwxrwxr-x 3 dev dev 4.0K Sep 11 21:18 prisma/
drwxrwxr-x 4 dev dev 4.0K Sep 11 19:18 src/
-rw-rw-r-- 1 dev dev 46 Sep 11 14:14 .env
-rw-rw-r-- 1 dev dev 189K Sep 11 21:19 package-lock.json
-rw-rw-r-- 1 dev dev 1.4K Sep 11 21:17 package.json
-rw-rw-r-- 1 dev dev 0 Sep 8 13:32 readme.md
-rw-rw-r-- 1 dev dev 776 Sep 11 20:34 tsconfig.json
package.json:
{
"name": "demo",
"version": "0.1.0",
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"db:init": "npx prisma generate",
"db:migrate": "npx prisma migrate dev"
},
"dependencies": {
"ajv": "^8.12.0",
"koa": "^2.14.2",
"koa-bodyparser": "^4.4.1",
"koa-compress": "^5.1.1",
"koa-override": "^3.0.0",
"@koa/cors": "^4.0.0",
"@koa/router": "^12.0.0",
"prisma": "^5.2.0",
"@prisma/client": "^5.2.0",
"@tsed/ajv": "^7.35.0",
"@tsed/common": "^7.35.0",
"@tsed/core": "^7.35.0",
"@tsed/di": "^7.35.0",
"@tsed/json-mapper": "^7.35.0",
"@tsed/platform-koa": "^7.35.0",
"@tsed/prisma": "^7.35.0",
"@tsed/schema": "^7.35.0"
},
"devDependencies": {
"@types/koa": "^2.13.8",
"@types/koa__cors": "^4.0.0",
"@types/koa__router": "^12.0.0",
"@types/koa-bodyparser": "^4.3.10",
"@types/koa-compress": "^4.0.3",
"@types/koa-override": "^3.0.0",
"@types/multer": "^1.4.7",
"@types/node": "^20.5.9",
"nodemon": "^3.0.1",
"typescript": "^5.2.2"
}
}
prisma/schema.prisma:
generator client {
provider = "prisma-client-js"
}
generator tsed {
provider = "@tsed/prisma"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model Demo {
/// @TsEd.Groups("!creation")
id Int @id @default(autoincrement())
uuid String @unique
data String
}
tsconfig.json:
{
"compilerOptions": {
"baseUrl": "./",
"outDir": "dist/",
"target": "esnext",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"declaration": false,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"noImplicitAny": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"allowSyntheticDefaultImports": true,
"importHelpers": true,
"preserveConstEnums": true,
"strictNullChecks": true,
"skipLibCheck": true,
"lib": [
"es7",
"dom",
"ESNext.AsyncIterable"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules/",
"dist/",
"public/",
"test/"
]
}
you've forgot to install the @tsed/prisma package.
The first step of the tutorial is pretty clear ;)
npm i -D prisma
npm i @tsed/prisma @prisma/client
Also the prisma schema seems to be wrong if we compare it to the given example:
generator tsed {
provider = "tsed-prisma"
}
Please follow the guideline ;)
Also, Ts.ED provide a CLI to generate a fresh project with Prisma feature. Don't hesitate to use it.
See you Romain