如何在VSCode中将环境变量添加到launch.json

编程入门 行业动态 更新时间:2024-10-22 21:30:30
本文介绍了如何在VSCode中将环境变量添加到launch.json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在node.js项目上使用新的VSCode编辑器.我正在尝试通过编辑launch.json文件来配置启动"配置文件以进行调试.我需要将连接字符串设置为环境变量.根据launch.json文件中的注释:

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 connectionstring as an environment variable. According to the comments in the launch.json file:

// Environment variables passed to the program. "env": { }

我尝试像这样添加我的环境变量:

I have tried adding my environment variable like so:

"env": { "CONNECTION_STRING": "Data Source=server;Initial Catalog=catalog;User ID=uid;Password=pwd;MultipleActiveResultSets=true" }

当我尝试启动我的应用程序时,这会导致错误; "OpenDebug进程意外终止".我尚未找到任何可以解释问题根源的日志文件等.

This causes an error when I try to launch my app; "OpenDebug process has terminated unexpectedly". I have not yet found any log files, etc. that might explain what the issue is.

当我设置环境变量并从标准命令提示符启动我的应用程序时,我知道此应用程序可以正常工作.如果我在launch.json文件中注释掉变量,该应用程序还将按预期运行;我只是无法连接到数据库.

I know this app works correctly when I setup the environment variable and launch my app from the standard command prompt. The app also runs as expected if I comment out my variable in the launch.json file; I just can't connect to the database.

我假设我在launch.json文件中使用了错误的格式,但是我还没有找到任何使之有效的方法.

I am assuming that I am using the wrong format in the launch.json file, but I have not yet found any way to make this work.

有什么想法吗?

推荐答案

Windows(可能是Linux)上的环境变量似乎存在问题.它确实可以在OS X上运行.我们正在调查中.期待尽快修复.

There seems to be a problem with environment variables on Windows (and probably on linux). It does work on OS X. We are investigating. Expect a fix soon.

安德烈·韦南(Andre Weinand), Visual Studio代码

Andre Weinand, Visual Studio Code

更新(2015年6月2日): Visual Studio Code 0.3.0包含针对此问题的修复程序.

Update (June 2, 2015): Visual Studio Code 0.3.0 contains a fix for this.

更多推荐

如何在VSCode中将环境变量添加到launch.json

本文发布于:2023-11-14 15:09:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587714.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中将   环境变量   如何在   json   VSCode

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!