Visual Studio Task Runner Error with ES6

I am running Visual Studio 2017 and use the Task Runner to run tasks in my gulpfile. I recently updated a gulp task to ES6 and now am getting this error:

Failed to run "C:\Users\nz9rcn\Code\WebUI\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
let fail = false;
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at task (C:\Users\nz9rcn\Code\WebUI\gulpfile.js:24:25)
at Object.<anonymous> (C:\Users\nz9rcn\Code\WebUI\gulpfile.js:37:23)
at Module._compile (module.js:397:26)

Can’t find a place to adjust the settings causing this error (strict mode). Please help. Thanks

Issue solved by un-checking the box for the Node.js binary used by Task Runner:

enter image description here

In the menu, go to Tools > Options > Projects and Solutions > Web Package Management > External Web Tools and DESELECT the option for $(VSINSTALLDIR)\Web\External

The version installed in that directory doesn’t support ES6 apparently.

References for solution here and here.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .
Read More:   Does javascript have to be in the head tags?

Similar Posts