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:
Installing Google Cloud Client Libraries for Node.js
The Google Cloud Client Library for Node.js is the idiomatic way for Node.js developers to integrate with Google Cloud Platform services, such as Cloud Datastore and Cloud Storage.
Here's an example of installing the Node.js client library for Cloud Storage:
To install the library locally with npm
:
npm install --save @google-cloud/storage
or with yarn
:
yarn add @google-cloud/storage
You can configure the Google Cloud Node.js libraries to handle authentication automatically or you can provide credentials manually.