typescriptgoogle-app-enginepackage.jsonapp.yamlgoogle-appengine-node

TypeScript project failing to deploy to App Engine targeting Node 12 or 14, but works with Node 10


I have a TypeScript project that has been deployed several times without any problems to Google App Engine, Standard environment, running Node 10. However, when I try to update the App Engine project to either Node 12 or 14 (by editing the engines.node value in package.json and the runtime value in app.yaml), the deploy fails, printing the following to the console:

> ####@1.0.1 prepare /workspace
> npm run gcp-build


> ####@1.0.1 gcp-build /workspace
> tsc -p .

sh: 1: tsc: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! ####@1.0.1 gcp-build: `tsc -p .`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the ####@1.0.1 gcp-build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

According to the following documentation, App Engine should be installing the modules listed in devDependencies in package.json prior to running the gcp-build script (which it has been doing, as expected, when deploying with the Node version set to 10).

https://cloud.google.com/appengine/docs/standard/nodejs/running-custom-build-step

I can't find any documentation regarding how this App Engine deployment behavior has changed when targeting Node 12 or 14 rather than Node 10. Is there some configuration I am missing? Or does Google no longer install devDependencies prior to running the gcp-build script?

Here is the devDependencies section of my package.json (TypeScript is there):

    "devDependencies": {
        "@google-cloud/nodejs-repo-tools": "^3.3.0",
        "@types/cors": "^2.8.12",
        "@types/express": "^4.17.13",
        "@types/pg": "^8.6.1",
        "@types/request": "^2.48.7",
        "tsc-watch": "^4.4.0",
        "tslint": "^6.1.3",
        "typescript": "^4.3.5"
    },

Solution

  • I encountered the exact same problem and just put typescript in dependencies, not devDependencies.

    It worked after that, but cannot assure that it is due to this change (since I have no proof of that).