How do I add environment variables to launch.json in VSCode

前端 未结 10 813
囚心锁ツ
囚心锁ツ 2020-12-08 01:29

Working with the new VSCode editor on a node.js project. I am attempting to configure my \"Launch\" profile for debugging by editing the launch.json file. I need to setup a

10条回答
  •  青春惊慌失措
    2020-12-08 02:24

    For reference, I came across a similar issue (in 2020, long after the bug mentioned in the accepted answer above was fixed) for a different language and would like to point out something:

    Accoding to Microsoft's documentation on launch configurations, many common options, including "env" are not requried features for all different debugging/run environments - that is to say, it seems to me that it is not VS Code that 'provides' the option for environment variables, but rather, the choice of the specific debugger extension to implement this feature. Therefore, either

    • An unexpected crash of the debugging application
    • the warning Property "env" is not allowed

    may occur because the particular language/debugger you are using doesn't support or hasn't implemented handling of environment variables.

    As qbiq has said, probably a quick workaround for this if the environment variables are not going to change across launches would be to export them and run VS Code with this specific set of variables set.

提交回复
热议问题