- I’m trying to deploy a backend file using Express + typescript + prisma via Elastic beanstalk.
- I tried various methods recommended in the official documentation.
I did a lot of searching and spent 4 days on it.
I think it might be related to package.json.
This is an error message that keeps occurring.
Node.js v20.12.2
[email protected] start
node build/app.js
/var/app/current/node_modules/.prisma/client/default.js:43
throw new Error(
^
Error: @prisma/client did not initialize yet. Please run “prisma generate” and try to import it again.
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report
at new PrismaClient (/var/app/current/node_modules/.prisma/client/default.js:43:11)
at Object. (/var/app/current/build/lib/prisma.js:4:14)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/var/app/current/build/controllers/post.js:54:32)
This is a GitHub link to the code file I am trying to distribute.
Github
Package.json Code
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"build": "npm run generate && tsc --project tsconfig.build.json",
"start": "node build/app.js",
"dev": "nodemon app.ts",
"generate": "npx prisma generate"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@aws-sdk/client-s3": "^3.569.0",
"@aws-sdk/s3-request-presigner": "^3.569.0",
"@prisma/client": "^5.13.0",
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"jsonwebtoken": "^9.0.2",
"multer": "^1.4.5-lts.1",
"nodemon": "^3.1.0",
"prisma": "^5.13.0",
"sharp": "^0.33.3"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/cookie-parser": "^1.4.7",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.6",
"@types/multer": "^1.4.11",
"@types/node": "^20.12.7",
"typescript": "^5.4.5"
}
}
Here are the methods I tried and the link to the document.
- Add the prisma CLI package to your dependencies instead of the devDependencies. (Making sure to run npm install afterward to update the package-lock.json).
- Or install your devDependencies on AWS Elastic Beanstalk instances. To do this you must set the AWS Elastic Beanstalk NPM_USE_PRODUCTION environment property to false.
3.you need to create an .npmrc file in the root of your project and add the following configuration.
official document