2017-07-21 40 views
1

我用:VS代碼任務2.0煩惱

  • VS代碼1.14.1
  • 任務2.0
  • 節點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 - 當我試圖運行與類型外殼\ 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 

[email protected] C:\Program Files\nodejs\node_modules\npm 

輸出#2 - 當我嘗試(gulp軟件包安裝爲全球(npm install gulp -g),(我有gulpfile.js正確的內容)):

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

clean: node_modules.bingulp.cmd: command not found 

我可以像通常一樣使用cmd中的gulp,npm,node和其他工具,它工作正常,但不在VS代碼中。

當前的這件事的解決方案:

  1. 每個東西創建批處理文件。
  2. 爲每個批處理文件創建shell任務(如scss.cmd)
  3. 運行這些任務。

是的,它運作良好,但您需要爲簡單的任務做太多的動作。

您可以在這方面提供什麼建議?

回答

2

我找到了解決這個問題的方法,問題出在默認的終端應用程序中。

默認情況下,在Windows操作系統 Visual Studio代碼使用PowerShell作爲終端的應用程序,在我的情況,我把它改成了混帳bash的應用程序,並得到了這個問題。之後,我將它改回到powershell,並且一切正常。

我沒有打擾爲什麼gitbash不起作用,可能需要在vs代碼的配置中進行額外的配置。

0

這是VS代碼中的issue。在命令結尾添加<,使其失敗。目前似乎沒有直接的解決辦法。