Typescript中的监视模式在tasks.json中不起作用

时间:2017-04-11 12:56:19

标签: typescript tsc

我使用VisualStudio Code作为我的文本编辑器。在我的打字稿项目中,我有一个.vscode文件夹,里面有tasks.json文件 当我使用以下配置时,

{
   "version": "0.1.0",
   "command": "tsc",
   "isShellCommand": true,
   "args": ["-p", "."],
   "showOutput": "silent",
   "problemMatcher": "$tsc"
}

正确构建了ts文件,没有任何错误 我想启用" compileOnSave"选项,以便我不必每次都运行构建。我还在任务中添加了手表参数。更改后,我的文件看起来像这样 tsconfig.json

{
   "compileOnSave": true,
   "compilerOptions": {
      "target": "es5",
      "module": "commonjs",
      "outDir": "jsFiles/",
      "sourceMap": true
   },
   "exclude": [
      "node_modules",
      "lib"
   ]
}  

tasks.json

{
   "version": "0.1.0",
   "command": "tsc",
   "isShellCommand": true,
   "args": ["-w", "-p", "."],
   "showOutput": "silent",
   "isBackground": true,
   "problemMatcher": "$tsc"
}  

但是上面的配置会引发如下错误:

fs.js:1402
throw error;
^
Error: watch . ENOSPC
    at exports._errnoException (util.js:1034:11)
    at FSWatcher.start (fs.js:1400:19)
    at Object.fs.watch (fs.js:1426:11)
    at Object.watchDirectory 
(/usr/lib/node_modules/typescript/lib/tsc.js:2377:32)
    at Object.executeCommandLine 
(/usr/lib/node_modules/typescript/lib/tsc.js:53355:43)
    at Object.<anonymous> 
(/usr/lib/node_modules/typescript/lib/tsc.js:53712:4)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
Watching build tasks has finished.  

我还尝试更改problemMatcher:$ tsc-watch,删除isBackground选项。但这些似乎都不起作用 但是当我运行tsc -w somefile.ts时,它正在运行 需要:我想启用compileOnSave并观看模式。

0 个答案:

没有答案