tsc - Der Überwachungsmodus in TypeScript funktioniert in tasks.json nicht
Ich verwende VisualStudio Code als meinen Texteditor. In meinem TypeScript-Projekt habe ich einen .vscode-Ordner und darin befindet sich die Datei tasks.json.
Wenn ich die folgende Konfiguration verwende,
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-p", "."],
"showOutput": "silent",
"problemMatcher": "$tsc"
}
Die TS-Dateien werden ohne Fehler korrekt erstellt.
Ich möchte die Option "compileOnSave" aktivieren, damit ich nicht jedes Mal den Build ausführen muss. Ich habe auch den Watch-Parameter in den Tasks hinzugefügt. Nach den Änderungen sehen meine Dateien wie folgt aus.
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"
}
Aber die obige Konfiguration wirft einen Fehler wie unten:
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.
Ich habe auch versucht, problemMatcher: $tsc-watch zu ändern, indem ich die isBackground-Option entfernt habe. Aber nichts davon scheint zu funktionieren.
Aber wenn ich tsc -w somefile.ts ausführe, funktioniert es.
Benötigt: Ich möchte compileOnSave und den Überwachungsmodus aktivieren.