如何在Visual Studio Code中为我的Electron应用程序使用$ {workspaceRoot}? [英] How do I use ${workspaceRoot} for my Electron app in Visual Studio Code?
问题描述
我有一个能够在Visual Studio Code中调试的Electron应用程序。升级到0.10.8版后,它将不再运行。
我在launch.json文件中收到以下错误消息:
I have an Electron app that I was able to debug in Visual Studio Code. After I upgraded to version 0.10.8 it will no longer run.
I am getting the error message below in my launch.json file:
相对路径将不再自动转换为绝对路径。考虑使用$ {workspaceRoot}作为前缀。
Relative paths will no longer be automatically converted to absolute ones. Consider using ${workspaceRoot} as a prefix.
要使用的运行时可执行文件的绝对路径。默认为PATH上的运行时可执行文件。
Absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
这是我的launch.json文件:
Here is my launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "My First Electron App",
"type": "node",
"request": "launch",
"program": "$(workspaceRoot}/app/main.js", //ERROR
"stopOnEntry": false,
"args": [],
"cwd": "$(workspaceRoot}",
"runtimeExecutable": "$(workspaceRoot}/node_modules/electron-prebuilt/dist/electron.app/Contents/MacOS/Electron", //ERROR
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858
}
]
}
我在两行中都提到了绿色的波浪线,结尾处有// ERROR。
I am getting the green squiggly line mentioned for the two lines with //ERROR at the end.
我看了这篇文章,但老实说,他对VS Code足够熟悉,可以理解应如何实现: https://code.visualstudio.com/Docs/editor/tasks#_variable-substitution
I saw this article, but honestly was familiar with VS Code enough to understand how this should be implemented: https://code.visualstudio.com/Docs/editor/tasks#_variable-substitution
更新 < br>
按照建议,我将 cwd
的值替换为 $ {workspaceRoot}
伊西多。弯曲的绿色线消失了。
UPDATE
I replaced the value for "cwd"
with "${workspaceRoot}"
as recommended by Isidor. The green squiggly line went away.
我更新了我在其他两行中仍然看到的错误消息。
I updated the error message that I am still seeing on the other two lines.
当我点击 F5
我收到此错误消息:
When I hit F5
I get this error message:
request'launch':运行时可执行文件'/私有/var/git/electron-vs-code/$(workspaceRoot}/node_modules/electron-prebuilt/dist/electron.app/Contents/MacOS/Electron'不存在
request 'launch': runtime executable '/private/var/git/electron-vs-code/$(workspaceRoot}/node_modules/electron-prebuilt/dist/electron.app/Contents/MacOS/Electron' does not exist
推荐答案
您的json中有一个错字。在 $
中的 $(workspaceRoot}
放在大括号中。这至少可以解决警告。
There is a typo in your json. Change the parenthesis after the $
in $(workspaceRoot}
to a curly brace. This should at least fix the warning.
这篇关于如何在Visual Studio Code中为我的Electron应用程序使用$ {workspaceRoot}?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!