I am trying to deploy my nestjs application to google app engine, but I get sh: 1: exec: nest: not found
error
my package.json
"main": "dist/main.js",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"gcp-build": "npm run build",
"ae:deploy": "gcloud app deploy --quiet",
"ae:browse": "gcloud app browse",
"@nestjs/cli": "^8.0.0",
}
DockerFile
FROM node:14-alpine
WORKDIR /usr/src/app
ENV NODE_ENV=production
COPY package*.json ./
RUN npm install -g @nestjs/cli@8
RUN npm install
COPY . ./
RUN npm run build
CMD [ "npm", "run", "start:prod" ]
app.yaml
runtime: nodejs14
service: default
instance_class: F1
env_variables:
NODE_ENV: 'production'
CloudBuild.yaml
steps:
- name: "gcr.io/cloud-builders/docker"
args:
- build
- "--tag=gcr.io/cmor-baas-dev/kafka-connector:latest"
- "--file=Dockerfile"
- .
images:
- "gcr.io/cmor-baas-dev/kafka-connector"
timeout: 1800s
I think both Dockerfile and CloudBuild.yaml files are ignored (I am new to Google app engine, not sure do we need those files)
Based on here,
All dependencies that you define under the devDependencies field are ignored and do not get installed for your app in App Engine.
So I moved @nestjs/cli
to dependencies
in my package.json, still same error
In case someone else came to this post looking for answer:
Two changes are needed:
1- update start script to "start": "node dist/main.js"
2- move @nestjs/cli
from devDependency
to dependency
Then it starts working
p.s Neither CloudBuild.yaml or Dockerfile is needed