Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

Running a custom build step

Stay organized with collections Save and categorize content based on your preferences.

At deployment, before starting your application, you can perform a custom build step by adding a gcp-build script in your package.json file.

When this script is executed, the dependencies in the dependencies and devDependencies fields of your package.json file are available. After executing your custom build step, App Engine removes and regenerates the node_modules folder by only installing the production dependencies declared in the dependencies field of your package.json file.


A custom build script can be used for pre-processing tasks, such as pre-processing CSS, minifying client side JavaScript, or running tools, such as webpack or gulp.

For example, to compile TypeScript to JavaScript, your package.json file might look like the following. Note the gcp-build script:

  "name": "appengine-typescript",
  "description": "An example TypeScript app running on Google App Engine.",
  "version": "0.0.1",
  "private": true,
  "license": "Apache Version 2.0",
  "author": "Google Inc.",
  "engines": {
    "node": "16.x.x"
  "scripts": {
    "prepare": "npm run gcp-build",
    "pretest": "npm run gcp-build",
    "test": "mocha test/*.test.js --exit",
    "lint": "gts lint",
    "start": "node ./index.js",
    "deploy": "gcloud app deploy",
    "clean": "gts clean",
    "compile": "tsc -p .",
    "fix": "gts fix",
    "build": "tsc -p .",
    "gcp-build": "tsc -p ."
  "dependencies": {
    "express": "^4.16.3"
  "devDependencies": {
    "@types/express": "^4.17.17",
    "@types/node": "^18.13.0",
    "chai": "^4.3.7",
    "gts": "^3.1.1",
    "mocha": "^10.2.0",
    "typescript": "^4.9.5",
    "wait-port": "^1.0.0"