Node.js Runtime Environment

The Node.js runtime is the software stack responsible for installingyour web service's code and its dependencies and running your service.

The Node.js runtime for App Engine in the standard environment isdeclared in theapp.yamlfile:

runtime:nodejsVERSION

WhereVERSION is the Node.jsMAJOR version number. Forexample, to use the latest Node.js version, Node.js 24, specify24.

For other supported Node.js versions, and the corresponding Ubuntu version for yourNode.js version, see theRuntime support schedule.

Node.js version

The latest supported Node.js version is 24. The Node.js runtime uses the latest stable release of the versionthat is specified in yourapp.yaml file. App Engine automatically updatesto new patch and minor release versions, but it will not automatically updatethe major version.

For example, your application might be deployed at Node.js 10.9.4 and laterautomatically updated to version 10.10.0, but it will not be automaticallyupdated to Node.js 12.x.x.

Because minor and patch versions are automatically updated, if present, theengines.node propertyin yourpackage.json file canonly specify the major version and be compatible with the Node.js versionspecified in yourapp.yaml file.

For example for 24:

  • 24.x.x
  • ^24.0.0
  • ~24
  • >=6

If you specify an incompatible Node.js version in yourpackage.json file,your deployment will fail with an error message.

Dependencies

During deployment, the runtime installs your dependencies using thenpm install command. The runtime alsosupports Yarn (yarn.lock) and Pnpm (pnpm-lock.yaml) package managers.For more information, seeSpecifying Dependencies.Because the runtime performs a fresh install, you do not need to upload yournode_modules folder.

Note: By default, the gcloud CLI does not upload yournode_modules folder.You can change which files are ignored using the.gcloudignore file.

To support Node.js packages that require native extensions, the runtime includessystem packages enabling you to use tools such asImageMagick,FFmpeg, andChrome headless.See the full list of packages atIncluded System Packages.To request a package,file an issue in the issue tracker.

NPM build script

By default, when you deploy the app in App Engine, the Node.js runtimeexecutesnpm run build if abuild script is detected inpackage.json. Ifyou require additional control over your build steps before starting yourapplication, you can provide acustom build stepby adding agcp-build script to yourpackage.json file.

To prevent your build from running thenpm run build script, you must either:

  • Add agcp-build script with an empty value in yourpackage.json file:"gcp-build":"". For details about configuring thepackage.json, seeNode.js buildpacks configurations.
  • Add theGOOGLE_NODE_RUN_SCRIPTSbuild environment variable with an empty value in yourapp.yaml file.

    build_env_variables:GOOGLE_NODE_RUN_SCRIPTS:''
For details about specifying build environment variables seebuild_env_variables section in theapp.yaml file.

Application startup

By default, the runtime starts your application by runningnode server.js.If you specify astart script in yourpackage.json file, the runtimeruns the specified start script instead. For example:

"scripts":{"start":"node app.js"}

For your app to receive HTTP requests, yourstart script should start a webserver that listens on host0.0.0.0 and the port specified by thePORTenvironment variable, which is accessible in Node.jsasprocess.env.PORT.

For the best performance, thestart script should be lightweight and excludebuild steps, because it runs whenever a new instance of your application iscreated.

You can override this behavior by specifying a script in theentrypoint fieldinapp.yaml. Instead of runningnode server.js or a start script, theruntime starts your application with the command you specifyinentrypoint.

Environment variables

The following environment variables are set by the runtime:

Environment variableDescription
GAE_APPLICATIONThe ID of your App Engine application.This ID is prefixed with 'region code~'such as 'e~' for applications deployed in Europe.
GAE_DEPLOYMENT_IDThe ID of the current deployment.
GAE_ENVThe App Engine environment. Set tostandard.
GAE_INSTANCEThe ID of the instance on which your service is currently running.
GAE_MEMORY_MBThe amount of memory available to the application process, in MB.
GAE_RUNTIMEThe runtime specified in yourapp.yaml file.
GAE_SERVICEThe service name specified in yourapp.yaml file. If no service name is specified, it is set todefault.
GAE_VERSIONThe current version label of your service.
GOOGLE_CLOUD_PROJECTThe Google Cloud project ID associated with your application.
PORTThe port that receives HTTP requests.
NODE_ENV (Only available in the Node.js runtime)Set toproduction when your service is deployed.

You candefine additional environment variables in yourapp.yaml file,but the above values cannot be overridden, except forNODE_ENV.

HTTPS and forwarding proxies

App Engine terminates HTTPS connections at the load balancer andforwards requests to your application. Some applications need to determinethe original request IP and protocol. The user's IP address is available inthe standardX-Forwarded-For header. Applications that require thisinformation should configure their web framework to trust the proxy.

WithExpress.js, use thetrust proxy setting:

app.set('trust proxy',true);

Note that settingtrust proxy totrue can open up thereq.ip property to IP spoofingvulnerability.

Filesystem

The runtime includes a full filesystem. The filesystem is read-only except forthe location/tmp, which is a virtual disk storing data in yourApp Engine instance's RAM.

Metadata server

Each instance of your application can use the App Engine metadata serverto query information about the instance and your project.

Note: Custom metadata is not supported in the standard environment.

You can access the metadata server through the following endpoints:

  • http://metadata
  • http://metadata.google.internal

Requests sent to the metadata server must include the request headerMetadata-Flavor: Google. This header indicates that the request was sent withthe intention of retrieving metadata values.

The following table lists the endpoints where you can make HTTP requests forspecific metadata:

Metadata endpointDescription
/computeMetadata/v1/project/numeric-project-idThe project number assigned to your project.
/computeMetadata/v1/project/project-idThe project ID assigned to your project.
/computeMetadata/v1/instance/regionThe region the instance is running in.
/computeMetadata/v1/instance/service-accounts/default/aliases
/computeMetadata/v1/instance/service-accounts/default/emailThe default service account email assigned to your project.
/computeMetadata/v1/instance/service-accounts/default/Lists all the default service accounts for your project.
/computeMetadata/v1/instance/service-accounts/default/scopesLists all the supported scopes for the default service accounts.
/computeMetadata/v1/instance/service-accounts/default/tokenReturns the auth token that can be used to authenticate your application to other Google Cloud APIs.

For example, to retrieve your project ID, send a request tohttp://metadata.google.internal/computeMetadata/v1/project/project-id.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.