Visual Studio任务运行错误与ES6 [英] Visual Studio Task Runner Error with ES6

查看:327
本文介绍了Visual Studio任务运行错误与ES6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Visual Studio 2017并使用Task Runner在我的 gulpfile 中运行任务。我最近更新了一个吞噬任务到ES6,现在得到这个错误:
$ b $ 未能运行C:\ Users \\\\\\\\\\\' Code\WebUI\Gulpfile.js...
cmd.exe / c gulp --tasks-simple
C:\Users\\\
z9rcn\Code\WebUI\gulp- tasks\lesslint.js:5
let fail = false;
^^^
SyntaxError:在严格模式之外尚未支持块范围声明(let,const,function,class)
位于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 (module.js:300:12)
at Module.require(module.js:353:17)
at require(internal /
在任务(C:\Users\\\
z9rcn\Code\WebUI\gulpfile.js:24:25)
在Object。< anonymous> (C:\ Users \ nz9rcn\Code\WebUI\gulpfile.js:37:23)
在Module._compile(module.js:397:26)

无法找到一个地方来调整导致此错误的设置(严格模式)。请帮忙。谢谢

解决方案

通过取消选中Task Runner使用的Node.js二进制文件b
$ b



在菜单中,转到工具> 选项> 项目和解决方案> code>> 外部Web工具和DESELECT $(VSINSTALLDIR)\Web\External



安装在该目录中的版本显然不支持 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 C:\Users\nz9rcn\Code\WebUI\gulp-tasks\lesslint.js:5 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:

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.

这篇关于Visual Studio任务运行错误与ES6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆