Using Node.js Libraries

Declaring and managing dependencies

Dependencies for Node.js applications are declared in a standard package.json file. For example:

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

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

During deployment, the Node.js runtime automatically installs all dependencies declared in your package.json file. By default the npm install command is used unless a yarn.lock file exists and is not listed in the app.yaml file's skip_files section, in which case yarn install --production is used instead.

Installing a web framework

You'll need to use a web framework to enable your app to serve web requests. You can use any Node.js web framework including the following:

To use a particular web framework, just add it to your package.json file:

  • Using NPM:

    npm install --save express
    
  • Using Yarn:

    yarn add express
    

Installing the Google Cloud Client library

The Google Cloud Client Library for Node.js is a client library for accessing Google Cloud Platform services that significantly reduces the boilerplate code you have to write. The library provides high-level API abstractions so they're easier to understand. It embraces idioms of Node.js, works well with the Node.js core modules, and integrates better with your codebase. This means you spend more time creating code that matters to you.

To install the library locally with NPM:

npm install --save google-cloud

or with Yarn:

yarn add google-cloud

The client library can automatically handle authentication for you locally as well by using the Google Cloud SDK:

gcloud beta auth application-default login

Send feedback about...

App Engine flexible environment for Node.js docs