Как следует установить переменные среды плагина vscode? - PullRequest
2 голосов
/ 21 июня 2020

Я пытался установить его с помощью cross-env, но после запуска с VSCode он не был определен. Как исправить?

введите описание изображения здесь

1 Ответ

1 голос
/ 21 июня 2020

Вы можете передавать переменные среды в расширения VS Code, которые вы запускаете локально, с помощью конфигурации запуска:

. /. Vscode / launch. json

// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Run Extension",
            "type": "extensionHost",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": [
                "--extensionDevelopmentPath=${workspaceFolder}"
            ],
            "outFiles": [
                "${workspaceFolder}/dist/extension.js"
            ],
            "preLaunchTask": "${defaultBuildTask}",
            "env": {
                "DEBUG": "true" // <---- EXAMPLE ENVIRONMENT VARIABLE
            }
        }
    ]
}
...