Node.js 14 is now generally available.

Specifying Dependencies

You specify the dependencies for your Node.js app by declaring them in the package.json file.

For example, if you want to use Lodash, your package.json file might look like:

  "dependencies": {
    "lodash": "^4.0.1"

When you deploy your app, the Node.js runtime automatically installs all dependencies using the npm install command or, if a yarn.lock file exists, the yarn install command.

By default, App Engine caches fetched dependencies to reduce build times. To install an uncached version of the dependency, use the command:

gcloud beta app deploy --no-cache

Support and limitations for the package.json file in the standard environment:

  • You can use any Linux-compatible Node.js package with App Engine, including packages that require native (C) extensions.

  • If the engines field is specified in your package.json, you must define a compatible Node.js version.

  • All dependencies that you define under the devDependencies field are ignored and do not get installed for your app in App Engine.

  • The start script should be lightweight and exclude build steps for the best performance because the script runs each time a new instance of your application is created.

Installing a web framework

We recommend you use a web framework to serve web requests. You can use any Node.js web framework including the following:

For example, to install and use Express.js, you can run one of the following commands:

  • Using npm:

    npm install express
  • Using yarn:

    yarn add express

For example, the resulting package.json file might look like the following:

  "dependencies": {
    "lodash": "^4.0.1",
    "express": "^4.16.2"