VS Code任务2.0的麻烦

时间:2017-07-21 15:53:39

标签: task visual-studio-code

我用:

  • VS Code 1.14.1
  • 任务2.0
  • node 6.11.1

我的问题是有些任务正在运行,有些则没有。

这是我的 tasks.json 文件。

{
    "version": "2.0.0",
    "tasks": [
        { // This task work fine.
            "label": "tsc",
            "type": "typescript",
            "tsconfig": "tsconfig.json",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        { // This task work fine.
            "taskName": "css",
            "type": "shell",
            "command": "./scss.sh",
            "windows": {
                "command": "./scss.cmd"
            },
            "presentation": {
                "reveal": "always",
                "panel": "new"
            }
        },        
        { // This task not work. (See output #1 below)
            "taskName": "npm-install",
            "type": "shell",
            "command": "npm install",
            "problemMatcher": [],
            "presentation": {
                "reveal": "always",
            }
        },
        { // This task not work. (See output #2 below)
            "type": "gulp",
            "task": "clean",
            "problemMatcher": []
        }            
    ]
}

输出#1 - 当我尝试使用类型 shell \ npm 运行npm任务时,我得到相同的结果:

> Executing task: npm install <


Usage: npm <command>

where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
    help, help-search, i, init, install, install-test, it, link,
    list, ln, login, logout, ls, outdated, owner, pack, ping,
    prefix, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, tag, team, test, tst, un, uninstall,
    unpublish, unstar, up, update, v, version, view, whoami

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    C:\Users\usr\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@3.10.10 C:\Program Files\nodejs\node_modules\npm

输出#2 - 当我尝试运行gulp任务时,我接下来(gulp包安装为全局(npm install gulp -g),(我有 gulpfile.js 正确的内容)):

> Executing task: node_modules\.bin\gulp.cmd clean <

clean: node_modules.bingulp.cmd: command not found

我可以像往常一样使用gdp,npm,node和cmd中的其他工具,它可以正常工作,但不能在VS代码中使用。

这件事的当前解决方案:

  1. 为每个东西创建批处理文件。
  2. 为每个批处理文件创建shell任务(作为scss.cmd)
  3. 运行这些任务。
  4. 是的,它运作良好,但你需要为简单的任务做太多的动作。

    你能在这方面提出什么建议?

2 个答案:

答案 0 :(得分:2)

I found a solution to this problem, the problem was in the default terminal application.

By default on Windows OS visual studio code use powershell as terminal app, in my case, I changed it to the git-bash app and got this problem. After that I changed it back to powershell and all works fine.

I did not bother about why gitbash does not work, it is possible that additional configuration is required in the configuration in the vs code.

答案 1 :(得分:0)

这是VS Code中的issue。在命令末尾添加<,使其失败。目前似乎没有直接解决方法。