Aller au contenu

Use ProductEnv in VS Code

The ProductEnv extension for VS Code shows, as you read code, which environments define each environment variable it uses, and warns about keys defined nowhere. It shows key names only: values are fetched only when you pull a file or copy one value.

Mis à jour le

Cette page n’est disponible qu’en anglais pour le moment.

Install and sign in

  1. Install ProductEnv from the Visual Studio Marketplace (VS Code 1.82 or newer).
  2. Link your project folder with npx productenv init if it has no .productenv.json yet: the extension starts in folders that have one.
  3. Run ProductEnv: Sign in, which runs productenv login in a terminal. The extension uses that CLI login.

No CLI login? ProductEnv: Use service token stores a service token in VS Code's secret storage for that project. It reads only the token's environment and takes priority over the CLI login; Clear service token removes it.

What it shows

  • Hover an environment variable read in JavaScript, TypeScript, Python, Ruby, Dart, C#, Java, Kotlin, Go or PHP, or a key in a .env file, to see which environments define it, which are protected, and its schema type and description.
  • Warnings for keys your code reads that no environment defines, and notes for required keys missing from an environment.
  • The Environments view in the ProductEnv activity bar lists each environment's keys, values masked.
  • Key lists are cached for 5 minutes; Refresh reloads them.

Commands

ProductEnv commands in the command palette
CommandWhat it does
Pull .envWrites .env, .env.local, .env.<environment> or a file you choose, and warns when git doesn't ignore it
Generate .env.exampleSaves key names, placeholders and comments, never values
Copy valueCopies one value after you confirm
Validate required keysLists the required keys each environment is missing
Open in dashboardOpens the linked environment in the dashboard
RefreshReloads the keys
Sign in / Use service token / Clear service tokenManage how the extension signs in
Open settingsOpens the extension's settings

Settings

settings.json
{
  // Empty: the CLI login's API, else https://api.product-env.com
  "productenv.apiUrl": "",
  "productenv.webUrl": "",
  "productenv.cliCommand": "productenv",
  "productenv.diagnostics.enabled": true,
  "productenv.diagnostics.ignoredKeys": ["NODE_ENV"],
  "productenv.telemetry.enabled": false
}

Usage statistics are off unless you turn on productenv.telemetry.enabled. They never include keys, values, file contents or tokens, and PRODUCTENV_TELEMETRY=0 or DO_NOT_TRACK=1 turn them off everywhere.