Office Add-in Node Debugger

1.0.7 · active · verified Sun Apr 19

The `office-addin-node-debugger` package facilitates web debugging for Office Add-ins by providing a Node.js instance to act as a proxy for the JavaScript runtime hosted by an Office application. It is a foundational component within the `Office-Addin-Scripts` monorepo, a collection of tools and utilities developed by OfficeDev for Office Add-in projects. While primarily intended as an underlying service, its programmatic interfaces can be imported into Node scripts for custom debugging workflows. The package ships with TypeScript types, promoting robust development. The current stable version is 1.0.6, last published about three months ago, suggesting a maintenance-oriented release cadence as part of a larger toolkit. This package differentiates itself by offering a Node.js-based proxy specific to the Office Add-in ecosystem, enabling integration with VS Code for a streamlined debugging experience, particularly against Edge runtimes.

Common errors

Warnings

Install

Imports

Quickstart

This TypeScript example demonstrates how to programmatically start and stop the Office Add-in Node Debugger proxy. It showcases typical configuration options like manifest path, development server port, and debugger port, providing a basic framework for integrating it into a custom build or test script.

import { startNodeDebugger, stopNodeDebugger } from 'office-addin-node-debugger';

async function setupAndStartDebugging() {
  // In a real scenario, these would come from environment variables or a configuration file.
  const manifestPath = process.env.ADDIN_MANIFEST_PATH ?? './manifest.xml';
  const devServerPort = parseInt(process.env.DEV_SERVER_PORT ?? '3000');
  const debuggerPort = parseInt(process.env.DEBUGGER_PORT ?? '9229');

  try {
    console.log('Starting Office Add-in Node Debugger...');
    const debuggerInstance = await startNodeDebugger({
      manifestPath,
      devServerPort,
      debuggerPort,
      verbose: true,
      // The 'app' option would typically specify the Office application (e.g., 'excel', 'word').
      // For programmatic use, you might need to infer this or provide it based on context.
      // app: 'excel',
    });
    console.log(`Node debugger proxy started on port ${debuggerPort}. Waiting for connection...`);

    // Simulate debugging session for a few seconds
    await new Promise(resolve => setTimeout(resolve, 15000));

    console.log('Stopping Node debugger...');
    await stopNodeDebugger(debuggerInstance.pid); // Assuming start returns an object with pid
    console.log('Node debugger stopped.');
  } catch (error: any) {
    console.error('Failed to start or stop node debugger:', error.message);
    process.exit(1);
  }
}

setupAndStartDebugging();

view raw JSON →