Setting Up Stackdriver Debugger on App Engine (Node.js)

Stackdriver Debugger is enabled for Node.js applications running on App Engine Flexible Environment by importing the Node.js StackDriver Debugger agent at the start of the application.

Stackdriver Debugger is compatible with Node.js version 0.12 or greater. Node.js version 5+ is recommended.

Installation

  1. Install with npm or add to your package.json:

    npm install --save @google-cloud/debug-agent

  2. Import the agent at the top of your main script (but after @google/cloud-trace if you are also using it):

    require('@google-cloud/debug-agent').start();
    

Sample application

'use strict';

require('@google-cloud/debug-agent').start();

const express = require('express');
const app = express();

app.enable('trust proxy');

app.get('/', (req, res) => {
  // Try using the StackDriver Debugger dashboard to inspect the "req" object
  res.status(200).send('Hello, world!');
});

// Start the server
if (module === require.main) {
  const PORT = process.env.PORT || 8080;
  app.listen(PORT, () => {
    console.log(`App listening on port ${PORT}`);
    console.log('Press Ctrl+C to quit.');
  });
}

Using the debugger

After deployment, you can use Stackdriver Debugger to capture and inspect the call stack and local variables in your application.

Send feedback about...

Stackdriver Debugger Documentation