I am using VisualStudio Code as my text editor. In my typescript project, I have a .vscode folder and inside that tasks.json file is present.
When I use the following configuration,
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-p", "."],
"showOutput": "silent",
"problemMatcher": "$tsc"
}
the ts files are built correctly without any error.
I want to enable "compileOnSave" option so that i don't have to run build everytime. I also added watch paramater in tasks. After the changes, my files look like this.
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"
}
But the above configuration throws an error like below:
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.
I also tried to change problemMatcher: $tsc-watch, removing isBackground option. But none of these seems to work.
But when I run tsc -w somefile.ts
, its working.
Need: I want to enable compileOnSave and watch mode.