Context:
I'm having an issue when I deploy my node app to GCP app engine.
The deployment has worked in the past, but I've not touched the code for a few months.
The deployment doesn't error, but when I click on the GCP url I get a 500 server error.
I noticed that after I deployed my version didn't have any instances and I believe it should of had two instances.
Message:
Error: Server Error The server encountered an error and could not complete your request. Please try again in 30 seconds.
I've taken a look at the logs which show the following:
Tech Stack:
NodeJs, NestJs, Express, GCP, Typescript
Error Message:
Error: Cannot find module '/workspace/dist/main'
Here is some more of the logs:
I'm not sure if theirs some permissions issue in i am that I need to add. I did receive an email about moving my app from Container Registry to Artifact Registry. So I'm not sure if thats effecting it or what I need to do.
Outcome:
Ideally like to understand why the server has a 500 error. The log messages are not helpful.
Dist folder after a nest build command run:
Deployment Steps:
I run npm run set-project:staging to select the correct app engine to deploy to.
Then I do nest build.
Then I do gcloud app deploy.
My app.yaml file:
runtime: nodejs16
env: standard
instance_class: F2
env_variables:
GOOGLE_NODE_RUN_SCRIPTS: ''
Package json:
{
"name": "backend-app",
"version": "0.0.2",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"main": "dist/main.js",
"scripts": {
"gcp-build": "",
"prebuild": "rimraf dist",
"local-build": "nest build",
"clean": "gts clean",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:prod": "node dist/main",
"start:dev": "nest start --watch",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"set-project:staging": "gcloud config set project hidden-staging",
"deploy:staging": "npm run set-project:staging && npm run local-build && gcloud app deploy",
"deploy:functions:staging": "firebase use staging && firebase deploy --only functions",
"gcloud-login": "gcloud auth application-default login"
},
"engines": {
"node": "16.x"
},
"dependencies": {
"@google-cloud/storage": "^6.2.0",
"@google-cloud/text-to-speech": "^4.0.0",
"@nestjs/cli": "^8.0.0",
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"@nestjs/jwt": "^8.0.0",
"@nestjs/passport": "^8.2.1",
"@nestjs/platform-express": "^8.0.0",
"@nestjs/swagger": "^5.2.0",
"@nestjs/throttler": "^2.0.1",
"@ntegral/nestjs-sendgrid": "^1.0.0",
"@sendgrid/mail": "^7.6.1",
"@types/passport": "^1.0.7",
"cookie-parser": "^1.4.6",
"csurf": "^1.11.0",
"firebase": "^9.6.10",
"firebase-admin": "^10.0.2",
"firebase-functions": "^3.18.1",
"passport": "^0.5.2",
"passport-firebase-jwt": "^1.2.1",
"pdf-puppeteer": "^1.1.10",
"puppeteer": "^15.5.0",
"raygun": "^0.13.2",
"reflect-metadata": "^0.1.13",
"request": "^2.88.2",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"swagger-ui-express": "^4.3.0"
},
"devDependencies": {
"@nestjs/schematics": "^8.0.0",
"@nestjs/testing": "^8.0.0",
"@types/cookie-parser": "^1.4.2",
"@types/express": "^4.17.13",
"@types/jest": "^27.0.1",
"@types/node": "^16.0.0",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"jest": "^27.0.6",
"prettier": "^2.3.2",
"supertest": "^6.1.3",
"ts-jest": "^27.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "^3.10.1",
"typescript": "^4.3.5"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
project.toml
[[build.env]]
name = "GOOGLE_NODE_RUN_SCRIPTS"
value = ""
Current Error:
Seems to only say 2 files for upload in the terminal?
500 error in browser and no instance in version :
Try the following command to the package json script:
"gcp-build": "nest build"
The documentation states to have gcp-build as an empty string. However, with a nest build we must add nest build inside the empty string.
Original resource from the chat above: https://cloud.google.com/appengine/docs/standard/nodejs/release-notes#April_11_2023
The app.yaml file:
runtime: nodejs16
env: standard
instance_class: F2