vscode插件的环境变量应如何设置?

时间:2020-06-21 02:25:13

标签: typescript visual-studio-code

我尝试使用cross-env进行设置,但是在使用VSCode运行后未定义。我该如何解决?

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以通过启动配置将环境变量传递给在本地运行的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
            }
        }
    ]
}