[英]Can't get Visual Studio Code to run my build command in launch.json
I have this command that I can run in a command prompt just fine and it works: 我有一个可以在命令提示符下运行的命令,它可以正常工作:
browserify -u jquery /public/index.js -t babelify -o /public/scripts/bundle.js & node /server.js
I'm trying to add it to the launch.json
program
section in VS Code but I keep getting errors like relative paths will no longer be converted to absolute ones
. 我试图将其添加到VS Code中的
launch.json
program
部分,但我不断收到错误,例如relative paths will no longer be converted to absolute ones
。
So I tried changing it to this: 所以我尝试将其更改为:
"program": "browserify -u jquery ${workspaceRoot}/public/index.js -t babelify -o ${workspaceRoot}/public/scripts/bundle.js & node ${workspaceRoot}/server.js"
And I'm still getting the same error. 而且我仍然遇到相同的错误。 I think it might need paths for browserify and other executables too but I'm not sure.
我认为它可能也需要用于browserify和其他可执行文件的路径,但我不确定。 I tried adding
${workspaceRoot}
to them as well but no luck: same error. 我也尝试向其中添加
${workspaceRoot}
,但没有运气:同样的错误。
Hmm, I'm very new to VS Code and not sure if this is right or not, but I found out I can just put the compilation part in a task ( tasks.json
) and run it with Control+Shift+B
. 嗯,我是VS Code的新手,不确定这是否正确,但是我发现我可以将编译部分放在一个任务(
tasks.json
)中,然后使用Control+Shift+B
运行它。
{
"version": "0.1.0",
"command": "browserify",
"isShellCommand": true,
"suppressTaskName": true,
"tasks": [
{
"taskName": "install",
"isBuildCommand": true,
"args": ["--u", "jquery", "${workspaceRoot}/public/index.js", "-t", "babelify", "-o", "${workspaceRoot}/public/scripts/bundle.js"]
}
]
}
And then manually run the server with this in the launch.json
: 然后在
launch.json
手动运行服务器:
"program": "${workspaceRoot}/server.js",
Seems to work, but it would be nice to have it all in one step. 似乎可以正常工作,但是一步一步就能完成。
Edit: Oh ok you can then add "preLaunchTask": "install",
to launch.json
to make it one step. 编辑:哦,好的,您可以将
"preLaunchTask": "install",
添加到launch.json
,使其一步。 Ok, solved! 好,解决了!
Ryan解决方案可能会起作用,只是在这里指出了什么地方出了错:模板构造(例如$ {workspaceRoot}和$ {cwd})在“ program”属性中不起作用,这就是为什么我们有“ args”的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.