如果未自动检测到,如何强制创建新的节点任务并启动配置?

时间:2019-07-04 17:19:22

标签: visual-studio-code vscode-tasks

场景: 我正在尝试将具有构建和启动任务的旧仓库/项目从旧的0.1.0格式升级到新的2.0格式。

我本来是想依靠任务文件中的智能功能,但是意识到我只会给我更多0.1.0格式任务的信息,却无济于事。 enter image description here

我认为好吧,让我们重新开始并删除现有的tasks.json。 然后激活“配置默认构建任务”

https://stackoverflow.com/questions/tagged/visual-studio-code

显示此菜单: enter image description here

然后这样: enter image description here

最终会生成以下内容:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "echo Hello"
        }
    ]
}

这是不正确的,我不想麻烦查找语法并进行编辑。我从经验中知道节点任务如下所示,并且可以自动生成。

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "identifier": "build",
            "type": "npm",
            "script": "build",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

我最终不得不重新启动VSCode,然后以某种方式自动检测到npm构建任务,该任务显示了

的预期/正确列表。

enter image description here

后来我才意识到VSCode第一次没有显示正确的列表的原因是它没有将其检测为NPM项目,而是在重新启动后发现了它的运行方式。

我的问题是,如果我知道我想要什么 如何强制生成节点任务? 以及启动配置?

我认为,如果您关闭了自动检测功能,那么必须有一种手动选择的方法吗?

我知道这两种类型都有智能感知功能,有时它没有显示正确的选项: enter image description here

0 个答案:

没有答案