While using typescript with Prisma, I encountered an issue when trying to run prisma generate
, as it kept throwing the following error:
TypeError: collection is not iterable.
at keyBy (/node_modules/@prisma/client/generator-build/index.js:57685:21)
at Object.getTypeMap (/node_modules/@prisma/client/generator-build/index.js:59468:17)
at new DMMFHelper (/node_modules/@prisma/client/generator-build/index.js:59365:25)
at new TSClient (/node_modules/@prisma/client/generator-build/index.js:60630:17)
at buildClient (/node_modules/@prisma/client/generator-build/index.js:60876:18)
at generateClient (/node_modules/@prisma/client/generator-build/index.js:60947:47)
at async LineStream.<anonymous> (/node_modules/@prisma/client/generator-build/index.js:54186:24)
Although I suspect there might be a problem with the settings, I haven't been able to pinpoint the exact reason for this issue.
The versions I am currently using are Prisma 3.9.2, @prisma/client 3.10.0, and macOS operating system.
This is my tsconfig.json file:
{
"compilerOptions": {
/* Language and Environment */
"target": "es2018",
/* Modules */
"module": "commonjs",
"moduleResolution": "node",
/* Emit */
"outDir": "./build",
"rootDir": "./src",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
/* Type Checking */
"strict": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}
This is my package.json file:
{
"scripts": {
"dev": "nodemon --watch \"src/**/*.ts\" --exec \"ts-node\" src/app.ts",
"build": "tsc -p tsconfig.json",
"start": "node build/app.js",
"prepare": "husky install",
"lint-staged": "lint-staged"
}
...
}
UPDATE: The issue has been resolved!
I managed to fix it by re-installing Prisma in the devDependencies section, and now everything is working smoothly.