【问题标题】:How can I run my electron project from Visual Studio Code如何从 Visual Studio Code 运行我的电子项目
【发布时间】:2016-03-26 12:42:51
【问题描述】:

我是 JavaScript 新手。我想在 Visual Studio Code 中创建一个带有电子框架的应用程序。 我正在开发debian。电子模块安装在本地,我可以从命令行执行我的应用程序。但不幸的是,我无法设置 VS 代码来运行它。我试过这个guide,但它没有帮助我。 我有以下launch.json:

{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
    {
        // Name of configuration; appears in the launch configuration drop down menu.
        "name": "Launch main.js",
        // Type of configuration. Possible values: "node", "mono".
        "type": "node",
        // Workspace relative or absolute path to the program.
        "program": "electron/main.js",
        // Automatically stop program after launch.
        "stopOnEntry": false,
        // Command line arguments passed to the program.
        "args": [],
        // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
        "cwd": ".",
        // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
        "runtimeExecutable": "node_modules/electron-prebuilt/dist/electron",
        // Optional arguments passed to the runtime executable.
        "runtimeArgs": [],
        // Environment variables passed to the program.
        "env": {
            "NODE_ENV": "development"
        },
        // Use JavaScript source maps (if they exist).
        "sourceMaps": false,
        // If JavaScript source maps are enabled, the generated code is expected in this directory.
        "outDir": null
    },
    {
        "name": "Attach",
        "type": "node",
        // TCP/IP address. Default is "localhost".
        "address": "localhost",
        // Port to attach to.
        "port": 5858,
        "sourceMaps": false
    }
]

}

如果我尝试执行,但出现一个空白终端并且 VS 代码显示“OpenDebug 进程已意外终止”。

更新:

同时,Visual Studio Code 也得到了很大的改进。这是一个很好的描述,应该如何为电子设置 VS 代码: http://electron.rocks/debugging-electron-in-vs-code/

【问题讨论】:

    标签: javascript visual-studio-code electron


    【解决方案1】:

    当您像这样运行电子时,您需要将参数传递给包含您的应用程序的目录。可能还有其他问题,但我认为您需要将程序设置为本地目录而不是文件:

    "program": ".",
    

    然后代码应该调用电子脚本并现在将"." 作为第一个参数传递。可能是 electron 也不支持调试选项,请尝试取消设置端口和地址属性。

    【讨论】:

      猜你喜欢
      • 2019-11-23
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多