Node.js Runtime Environment Stay organized with collections Save and categorize content based on your preferences.
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.
node_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 a
gcp-buildscript with an empty value in yourpackage.jsonfile:"gcp-build":"". For details about configuring thepackage.json, seeNode.js buildpacks configurations. Add the
GOOGLE_NODE_RUN_SCRIPTSbuild environment variable with an empty value in yourapp.yamlfile.build_env_variables:GOOGLE_NODE_RUN_SCRIPTS:''
build_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 variable | Description |
|---|---|
GAE_APPLICATION | The ID of your App Engine application.This ID is prefixed with 'region code~'such as 'e~' for applications deployed in Europe. |
GAE_DEPLOYMENT_ID | The ID of the current deployment. |
GAE_ENV | The App Engine environment. Set tostandard. |
GAE_INSTANCE | The ID of the instance on which your service is currently running. |
GAE_MEMORY_MB | The amount of memory available to the application process, in MB. |
GAE_RUNTIME | The runtime specified in yourapp.yaml file. |
GAE_SERVICE | The service name specified in yourapp.yaml file. If no service name is specified, it is set todefault. |
GAE_VERSION | The current version label of your service. |
GOOGLE_CLOUD_PROJECT | The Google Cloud project ID associated with your application. |
PORT | The 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://metadatahttp://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 endpoint | Description |
|---|---|
/computeMetadata/v1/project/numeric-project-id | The project number assigned to your project. |
/computeMetadata/v1/project/project-id | The project ID assigned to your project. |
/computeMetadata/v1/instance/region | The region the instance is running in. |
/computeMetadata/v1/instance/service-accounts/default/aliases | |
/computeMetadata/v1/instance/service-accounts/default/email | The 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/scopes | Lists all the supported scopes for the default service accounts. |
/computeMetadata/v1/instance/service-accounts/default/token | Returns 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.