რედაქტირება

Quickstart: Upgrade npm packages in a JavaScript or TypeScript project by using GitHub Copilot modernization

This quickstart shows you how to use GitHub Copilot modernization to upgrade npm packages in a JavaScript or TypeScript project. GitHub Copilot modernization for JavaScript/TypeScript analyzes your project, suggests an upgrade plan, automatically upgrades packages, and helps you apply any necessary code changes.

Prerequisites

Open the project

Open your JavaScript or TypeScript project folder in Visual Studio Code. The project must contain a package.json file for the tool to detect it.

Start the upgrade

To start the npm package upgrade process, use the following steps:

  1. In Visual Studio Code, open the GitHub Copilot modernization panel from the Activity Bar on the left side of the window.

  2. In the panel, select the Upgrade npm Packages button. This button only appears if the tool detects a package.json file in your project.

  3. The Copilot Chat window opens automatically. Copilot analyzes your project and proposes an upgrade plan. Review the plan in the chat window.

  4. Follow the prompts in Copilot Chat. Copilot asks questions and requests confirmations as it walks you through each stage of the upgrade. The tool is interactive, so answer questions in the chat as they appear.

  5. Copilot upgrades your package.json file, runs the appropriate package-manager commands for your project (such as npm install, npm update, pnpm install, or yarn install), and suggests code changes if any breaking changes or API updates require modifications.

Behind the scenes, the tool operates in an iterative loop: it analyzes the project, makes changes, verifies the build or checks for issues, and repeats as necessary. This process runs in Copilot's agent mode to provide intelligent, context-aware assistance. The tool creates a dedicated branch for the upgrade session and commits changes to that branch automatically as it works.

Review changes and create a pull request

When the upgrade session completes, review what the tool did and decide whether to merge the work:

  1. Open summary.md under <project>/.github/modernize/code-migration/<timestamp>/ for an overview of what the upgrade session changed.

  2. Use the Visual Studio Code source control panel to review the commits the tool made on the upgrade branch.

  3. Run your project's build and test scripts to verify the upgraded project behaves as expected.

  4. When you're satisfied with the changes, create a pull request from the upgrade branch into your main branch using your preferred Git workflow.

Next steps