Search code examples
reactjsgoogle-app-enginegoogle-cloud-platform

Google App Deploy stopped working for React APP with could not fine index.js file error


I have a React app that is deployed as a GCP App Engine Service. My App Engine runtime is nodejs14. It was working fine up until 20th April but then something changed from GCP side and the deployment started failing with "cannot find the required file - index.js" error.

enter image description here

The file is indeed present in my source and as I said, I haven't changed anything in the project that is also reflected with git status (so there is no possibility of deleting/moving the index.js file)

This only happens with gcloud deployment - the local build is successful and also the project runs without compilation issues (with npm run start).

Things I have tried:

  1. I have tried both approaches for deployment using gcloud app deploy and also configured a build job through a cloudbuild.yaml with no success.
  2. The build also fails when ci/cd pipeline is triggered through github actions.

Here is my app.yaml file:

enter image description here

Gcloud version: Google Cloud SDK 360.0.0 bq 2.0.71 core 2021.10.04 gsutil 5.3


Solution

  • As per @NoCommandLine's comment, there's a breaking change when deploying Nodejs buildpacks on Google App Engine. According to the April 11, 2023 release notes:

    For all the services using the Node.js runtime, npm run build now automatically runs during deployment if you have the npm build script defined in your package.json file.

    In order to prevent your build from running the npm run build script, you must either: