CLI tool
GoogleCloudPlatform/nodejs-docs-samples avatar
GoogleCloudPlatform/nodejs-docs-samples

GoogleCloudPlatform/nodejs-docs-samples: what the repository actually contains and how to run one sample

Node.js samples for Google Cloud Platform products.

2,994 stars2,037 forksJavaScriptApache-2.0

At a glance

What is it?
A monorepo of Node.js samples for Google Cloud products, not a library you install. Here is the layout, the per-sample workflow, and the cases where it is the wrong starting point.
Who is it for?
Adopt it if you want a runnable reference for a specific Google Cloud service and are willing to read the README inside that service's directory, since the root README only describes the shared workflow. Do not adopt it as an application scaffold: the root package.json is marked private, the root test script exits with an error, and there is no single install that covers the tree.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly JavaScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What nodejs-docs-samples is for

This repository is the source of the Node.js code that appears on cloud.google.com. The root README points readers to the Google Cloud Samples page for browsing documentation pages that use these samples, and the package.json description is simply "Node.js samples found on https://cloud.google.com". That framing matters more than it looks. The unit of work is a single sample directory, not the repository. If you want to see how a Pub/Sub subscriber is wired, how a Cloud Run handler is exported, or how a particular client library is called, you open that folder and read the file. The audience is developers who already know which Google Cloud product they are integrating and want a working call sequence rather than a prose description of one. It is also useful for people preparing for a migration, because the samples show the current client library surface rather than an older blog post's version of it.

How the monorepo is laid out and why the root has almost no code

The top level is a set of product directories: ai-platform, appengine, asset, auth, automl, batch, bigquery, cloud-sql, cloud-tasks, compute, dataproc, dialogflow, dlp, document-ai, eventarc, functions, genai, healthcare, iam, kms, monitoring, pubsub, and roughly two dozen more. Each holds one or more sample folders. There is no shared runtime package that the samples import. The root package.json is marked "private": true and its dependencies are tooling only: gts for linting, mocha, c8, prettier, typescript, nunjucks, and commander. That is deliberate. A shared dependency tree across hundreds of samples covering different client library versions would be unmaintainable, so each sample carries its own package.json and its own install step. The consequence for you is that cloning the repository gives you source files and nothing runnable. The root test script makes the same point bluntly: it prints "Please run tests in each sample directory." and exits with status 1. If you run npm test at the top level expecting a suite, you get a failure by design.

Installing the toolchain and running your first sample

The README lists three prerequisites: Node.js version 18 or greater, the Google Cloud CLI, and authentication credentials. The engines field in package.json agrees, requiring node >=18.0.0. Clone the repository first, then authenticate. The README gives this command for creating local credentials, and it opens an oauth2 flow in your browser:

bash
gcloud auth application-default login

After that, pick a sample. The README uses run/helloworld as its example, so change into it and install that folder's dependencies:

bash
cd run/helloworld
npm install

Some samples have a TypeScript variant, and for those the README adds a build step before running:

bash
npm run build

Then start it. The README shows the start script taking optional arguments:

bash
npm start [args]...

What you see depends entirely on the sample: a local HTTP server that responds on a port, a script that prints a result and exits, or a process that waits for messages. The repository also ships a Makefile for the developer workflow. It defaults dir to the current directory, and you can point it at a subdirectory:

bash
make lint build dir=translate/snippets

The Makefile exports GOOGLE_CLOUD_PROJECT from a GOOGLE_SAMPLES_PROJECT environment variable, and its check-env target raises an error if GOOGLE_SAMPLES_PROJECT is unset when you run make test. So if you use make rather than npm directly, set that variable first.

Where the repository stops helping you

The root README does not document rollback, upgrade paths, or how a sample maps to a production deployment. It documents how to run one. That gap is not an oversight so much as a boundary: samples are written to be short enough to read in a documentation page, which means error handling, retries, and configuration management are usually trimmed to the minimum needed to demonstrate a call. Treating a sample as production code will leave you to supply all of that yourself. The second limitation is version drift. Each sample pins its own client library version, and nothing in the repository guarantees that two samples use the same major version of a shared library. If you copy code from three directories into one service, you are the one reconciling the dependencies. The third is discoverability. With product directories at the top level and no index file listing every sample, finding the right folder means knowing the product name first. The README's pointer to the Google Cloud Samples page is the intended route, and it filters by language, so it is worth using instead of browsing the tree. Finally, the samples are not a supported product. The CONTRIBUTING.md and SECURITY.md files exist, and contributions are welcomed, but there is no compatibility commitment attached to any individual sample.

nodejs-docs-samples compared with the official client libraries

The obvious alternative is to skip the repository and work directly from the @google-cloud client libraries and their generated API reference. The difference in approach is real. A client library gives you the full surface of an API, generated and versioned, with types and reference documentation for every method. The samples give you one opinionated path through a small part of that surface, written to match a specific documentation page. If your task is "call this method with these parameters", the library reference is faster and more complete. If your task is "show me the shape of a working integration for this product, including which other services it touches", the sample is faster, because someone already made the choices. A second alternative is the Google Cloud Node.js getting-started material that the README links to at cloud.google.com/nodejs, plus the Bookshelf tutorial app, which the README describes as a sample web app showing how to use a variety of Google Cloud features. Bookshelf is a single coherent application; this repository is a collection of fragments. If you learn better from one application that grows, follow Bookshelf. If you need the fragment for the one service you are integrating today, stay here.

Licence, maintenance and the cost of keeping up

The repository is Apache-2.0, stated in both the LICENSE file and the package.json license field. Apache-2.0 permits commercial use and modification and includes an explicit patent grant, which is the usual reason a company prefers it over MIT for code it may copy into a product. It also requires that you preserve the licence and notice files for the parts you reuse. That is a general description of the licence, not legal advice; check with your own counsel if the code ends up in something you ship. On maintenance, the last push to the default branch was on 2026-09-23, and the repository is not archived. The upgrade cost is the part people underestimate. Because dependencies are per directory, a security advisory in a client library means updating every sample folder that pins it, and there is no root-level lockfile to bump. The Makefile's lint and fix targets run gts against a directory, so the tooling for keeping a sample tidy exists, but the decision to update a pinned version is made per folder. If you copy a sample into your own repository, you take on that version tracking permanently, and the upstream fix will not reach you automatically.

Editorial conclusion

Adopt it if you want a runnable reference for a specific Google Cloud service and are willing to read the README inside that service's directory, since the root README only describes the shared workflow. Do not adopt it as an application scaffold: the root package.json is marked private, the root test script exits with an error, and there is no single install that covers the tree. Before writing any code, verify three things: that the sample directory you picked has its own README with the environment variables it needs, that your project has the APIs that sample calls enabled, and that gcloud auth application-default login has produced credentials your shell can see.

Frequently asked questions

What is GoogleCloudPlatform/nodejs-docs-samples?

It is a monorepo of Node.js samples for Google Cloud Platform products, and the package.json describes it as "Node.js samples found on https://cloud.google.com". The root package.json is private and contains only linting and test tooling, so the runnable code lives in the individual product directories.

What are some good examples of Node.js projects to read?

This repository is one: it collects samples for products such as bigquery, pubsub, functions, cloud-sql and dialogflow, each in its own folder with its own dependencies. The README also points to the Bookshelf tutorial app, described as a sample web app that shows how to use a variety of Google Cloud Platform features.

Is Node.js difficult to learn, and does this repository assume prior experience?

The repository does not teach Node.js. Its setup section assumes you install Node.js version 18 or greater and the Google Cloud CLI before cloning, and each sample is a short program rather than a lesson. No claim is made about the learning curve.

Official sources

  1. GoogleCloudPlatform/nodejs-docs-samples on GitHub
  2. Issues
  3. License: Apache-2.0
  4. Project website
  5. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/googlecloudplatform-nodejs-docs-samples.svg)](https://hysenlabs.com/projects/googlecloudplatform-nodejs-docs-samples)