简体   繁体   English

无法获取Visual Studio代码在launch.json中运行我的构建命令

[英]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.

相关问题 我应该如何配置我的 Visual Studio Code launch.json 以使其显示变量和属性值? - How should I configure my Visual Studio Code launch.json in order for it to show variables and property values? “。”(点)在launch.json的Visual Studio代码“ runtimeArgs”属性中做什么 - What does “.” (Dot) do in Visual Studio Code “runtimeArgs” property of launch.json Visual Studio Code:在浏览器中打开当前的 HTML 文件 (launch.json) - Visual Studio Code: Open current HTML file in browser (launch.json) vs代码:launch.json - vs code : launch.json Visual Studio中的构建后Vue应用程序提供了“命令npm run build with code 1” - Post-build Vue application in Visual Studio gives a “The command npm run build exited with code 1” 无法使用 Visual Studio Code 终端运行节点文件 - Can't run node file using Visual Studio Code terminal 如何从Visual Studio Code运行我的电子项目 - How can I run my electron project from Visual Studio Code 我的 jsconfig.json 不能在 Visual Studio Code 中运行吗? - Is my jsconfig.json not working in Visual Studio Code? 有人可以修复我的代码以复制按钮吗? (Visual Studio 代码) - Can someone fix my code for a button to copy? (Visual Studio Code) 在 Visual Studio Code 中运行 JavaScript - Run JavaScript in Visual Studio Code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM