从 VS 2015 Task Runner Explorer 运行时 Gulp 任务失败,但不是从命令提示符 [英] Gulp task failing when run from VS 2015 Task Runner explorer, but not from command prompt

查看:29
本文介绍了从 VS 2015 Task Runner Explorer 运行时 Gulp 任务失败,但不是从命令提示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些 Gulp 任务来为网站执行典型的 cleanbuildrelease 操作.在我看来没有什么特别不寻常的.(实际上它与 Aurelia TypeScript 骨架非常相似.)

团队中的大多数人使用 Gulp 在 PowerShell/命令提示符下进行前端开发,并使用 VS Code/Sublime 进行编辑.一些团队使用 Visual Studio 2015 做同样的事情.

从命令提示符运行 build 任务工作正常,但如果我们从 Visual Studio 的 Task Runner Explorer 运行它,它会给我们一个错误.

但是,从命令提示符和 VS Task Runner Explorer 运行其他任务(例如 clean)都可以正常工作.

有趣的是,Task Runner 资源管理器甚至会输出它为运行任务而调用的进程的副本.如果我复制那个确切的命令(见下文)并在命令提示符下运行它,它不会给出错误.它仅在从 Task Runner Explorer 运行时发生,并且只有一项任务.

以下是 Task Runner Explorer 的任务命令行和相关错误输出:

cmd.exe/c gulp -b "D:DevelopmentxxxxWebSite" --color --gulpfile "D:DevelopmentxxxxWebSiteGulpfile.js" build[20:40:42] 使用 gulpfile D:DevelopmentxxxxWebSiteGulpfile.js[20:40:42] 开始构建"……[20:40:42] 开始干净"......[20:40:42] 5.74 毫秒后完成清理"[20:40:42] 开始构建系统"……[20:40:42] 开始'build-html'...[20:40:42] 开始'build-css'...[20:40:42] 31 毫秒后完成构建 css"[20:40:43] 162 毫秒后完成build-html"D:DevelopmentxxxxWebSite
ode_modulesgulp-tsblibuilder.js:153var newLastBuildVersion = new Map();^参考错误:地图未定义在 Object.build (D:DevelopmentxxxxWebSite
ode_modulesgulp-tsblibuilder.js:153:39)<匿名>(D:DevelopmentxxxxWebSite
ode_modulesgulp-tsblibindex.js:40:22)在 _end (D:DevelopmentxxxxWebSite
ode_modules	hroughindex.js:65:9)在 Stream.stream.end (D:DevelopmentxxxxWebSite
ode_modules	hroughindex.js:74:5)在 DestroyableTransform.onend (D:DevelopmentxxxxWebSite
ode_modules
eadable-streamlib\_stream_readable.js:545:10)在 DestroyableTransform.g (events.js:180:16)在 DestroyableTransform.emit (events.js:117:20)在 endReadableNT (D:DevelopmentxxxxWebSite
ode_modules
eadable-streamlib\_stream_readable.js:960:12)进程以代码 8 终止.at afterTick (D:DevelopmentxxxxWebSite
ode_modulesprocess-nextick-argsindex.js:18:8)在 process._tickCallback (node.js:419:13)

我的 Google-Fu 在错误消息/堆栈跟踪或相关搜索中显示为空.

是什么?

更新:根据@josh-graham,VS 调用的 Node 版本如下所示.

[10:12:48] 开始干净"...版本:v0.10.31[10:12:48] 42 毫秒后完成清理"

解决方案

VS 附带一个旧版本的 Node.js,并没有表明更新是否会很快到来,即使有

查看更多详情 - 在 Visual Studio 2015 中自定义外部 Web 工具.另外,对于图片很抱歉,但这似乎是解释问题的最直接方式.

<小时>

在看到这个答案越来越受欢迎以帮助他人后,我继续深入研究为什么这仍然是一个问题.我查看了当前的 Node.js Tools 更新说明3仍然 在他们的更新摘要中没有看到任何有关版本的信息,如下所示...

<块引用>
  • 更快、更好的 ES6 智能感知
  • 更可靠的调试
  • 改进了单元测试体验(包括磁带支持)
  • .npm 命令在更多项目类型中

为了看看他们的确切版本选择是否非常明显(事实并非如此),我做了一点在他们的github仓库中找到以下内容...

this.versions = {node: '0.10.0', v8: '3.14.5.8'};

会是这样吗?不确定,但我认为他们仍然不支持使用较新版本的 Node.js 发布 VS.

I have some Gulp tasks to do the typical clean, build, release actions for a website. Nothing particularly unusual in my mind. (In fact it's very similar to Aurelia TypeScript skeleton.)

Most of the team does front-end development using Gulp from a PowerShell / Command prompt and editing with VS Code / Sublime. Some of the team does the same using Visual Studio 2015.

Running the build task from the command prompt works just fine, but if we run it from Visual Studio's Task Runner Explorer, it gives us an error.

However, running the other tasks (e.g. clean) works just fine from both the command prompt and the VS Task Runner Explorer.

Interestingly, the Task Runner explorer even outputs a copy of the process it invokes to run the task. If I copy that exact command (see below) and run that in a command prompt, it does not give the error. It only happens when run from Task Runner Explorer, and only that one task.

Here's the task command line and related error output from the Task Runner Explorer:

cmd.exe /c gulp -b "D:DevelopmentxxxxWebSite" --color --gulpfile "D:DevelopmentxxxxWebSiteGulpfile.js" build
[20:40:42] Using gulpfile D:DevelopmentxxxxWebSiteGulpfile.js
[20:40:42] Starting 'build'...
[20:40:42] Starting 'clean'...
[20:40:42] Finished 'clean' after 5.74 ms
[20:40:42] Starting 'build-system'...
[20:40:42] Starting 'build-html'...
[20:40:42] Starting 'build-css'...
[20:40:42] Finished 'build-css' after 31 ms
[20:40:43] Finished 'build-html' after 162 ms
D:DevelopmentxxxxWebSite
ode_modulesgulp-tsblibuilder.js:153
        var newLastBuildVersion = new Map();
                                      ^
ReferenceError: Map is not defined
    at Object.build (D:DevelopmentxxxxWebSite
ode_modulesgulp-tsblibuilder.js:153:39)
    at Stream.<anonymous> (D:DevelopmentxxxxWebSite
ode_modulesgulp-tsblibindex.js:40:22)
    at _end (D:DevelopmentxxxxWebSite
ode_modules	hroughindex.js:65:9)
    at Stream.stream.end (D:DevelopmentxxxxWebSite
ode_modules	hroughindex.js:74:5)
    at DestroyableTransform.onend (D:DevelopmentxxxxWebSite
ode_modules
eadable-streamlib\_stream_readable.js:545:10)
    at DestroyableTransform.g (events.js:180:16)
    at DestroyableTransform.emit (events.js:117:20)
    at endReadableNT (D:DevelopmentxxxxWebSite
ode_modules
eadable-streamlib\_stream_readable.js:960:12)
Process terminated with code 8.
    at afterTick (D:DevelopmentxxxxWebSite
ode_modulesprocess-nextick-argsindex.js:18:8)
    at process._tickCallback (node.js:419:13)

My Google-Fu has come up empty on the error message / stack trace or related searches.

What gives?

UPDATE: As per @josh-graham, the version of Node being invoked by VS is listed below.

[10:12:48] Starting 'clean'...
Version: v0.10.31
[10:12:48] Finished 'clean' after 42 ms

解决方案

VS ships with an old version of Node.js and does not indicate whether an update will be coming any time soon, even with Update 2 coming out. Your system likely has a newer version. To fix this in Visual Studio, you need to prioritize your PATH (assuming you have node on your PATH). Simply find the "External Web Tools" option, and move $(PATH) to the top of the following...

See this for more detail - Customize external web tools in Visual Studio 2015. Also, sorry for the picture, but it seems to be the most straightforward way to explain the issue.


After seeing this answer grow in popularity to help others, I continued to dig into why this is still somehow an issue. I looked into the current Node.js Tools remarks for update 3 and still do not see any information regarding a version in their summary of updates as follows...

  • Faster, better ES6 IntelliSense
  • More reliable debugging
  • Improved Unit Testing experiences (including Tape support)
  • .npm command in more project types

To go down the rabbit hole a little bit to see if their exact version choice is glaringly obvious (which it is not) I did find the following on their github repository...

this.versions = {node: '0.10.0', v8: '3.14.5.8'};

Could this be it? Unsure, but I'm thinking they're still not on board with shipping VS with newer versions of Node.js.

这篇关于从 VS 2015 Task Runner Explorer 运行时 Gulp 任务失败,但不是从命令提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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