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

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

问题描述

我有一些 Gulp 任务来执行典型的 clean , build 发布网站操作。在我心中没有什么特别的。



大部分团队使用来进行前端开发, Gulp 从PowerShell /命令提示符处进行编辑并使用VS Code / Sublime进行编辑。有些团队使用Visual Studio 2015做同样的事情。



从命令运行 build 任务提示符工作得很好,但是如果我们从Visual Studio的Task Runner Explorer运行它,它会给我们一个错误。 然而,运行其他任务(例如 clean )可以在命令提示符和VS Task Runner Explorer中正常工作。

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



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

  cmd.exe / c gulp -bD:\ Development \xxxx\WebSite--color --gulpfileD: \ Development \xxxx\WebSite\Gulpfile.jsbuild 
[20:40:42]使用gulpfile D:\ Development \xxxx\WebSite\Gulpfile.js
[ 20:40:42]开始'建立'...
[20:40:42]开始'干净'...
[20:40:42] 5.74 ms后完成'clean'
[20:40:42]启动'build-system'...
[20:40:42]开始'build-html'...
[20:40:42]启动'build-css'...
[20:40:42] 31 ms后完成'build-css'
[20:40:43] 162 ms后完成'build-html'
D:\ Development \xxxx\WebSite\\\
ode_modules\gulp-tsb\lib\builder.js:153
var newLastBuildVersion = new Map();
^
ReferenceError:在Object.build(D:\ Development \xxxx\WebSite\\\
ode_modules\gulp-tsb\lib\builder)中未定义映射
。 js:153:39)
在Stream。< anonymous> (D:\ Development \xxxx\WebSite\\\
ode_modules\gulp-tsb\lib\index.js:40:22)$ _b在_end(D:\Development\xxxx\ WebSite\\\
ode_modules\through\index.js:65:9)
Stream.stream.end(D:\Development\xxxx\WebSite\\\
ode_modules\through\index.js :74:5)
在DestroyableTransform.onend(D:\Development\xxxx\WebSite\\\
ode_modules\readable-stream\lib\_stream_readable.js:545:10)
在DestroyableTransform.g(events.js:180:16)
在DestroyableTransform.emit(events.js:117:20)
在endReadableNT(D:\Development\xxxx\WebSite\ node_modules\readable-stream\lib\_stream_readable.js:960:12)
进程以代码8结束。
at afterTick(D:\ Development \xxxx\WebSite\\\
ode_modules \ process-nextick-args\index.js:18:8)
at process._tickCallback(node.js:419:13)

我的Google-Fu在错误消息/堆栈跟踪或相关搜索中出现空白。

给出了什么?

更新:根据@ josh-graham,由VS调用的节点版本

  [10:12:48]开始'清理'... 
版本:v0。 10.31
[10:12:48] 42 ms后完成'clean'


解决方案

VS附带旧版本的Node.js,并不表示更新是否即将推出,即使使用。此外,对于图片感到抱歉,但它似乎是解释问题最直接的方式。






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



  • 更快,更好的ES6 IntelliSense

  • 更可靠的调试

  • 改进的单元测试体验(包括磁带支持)

  • .npm命令用于更多项目类型


沿着兔子洞走一点,看看它们的确切版本的选择是否显而易见(它不是)我做了在他们的github仓库中找到以下内容 ...

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

这可能吗?不确定,但我认为他们仍然没有将VS与更新版本的Node.js一起装船。


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:\Development\xxxx\WebSite" --color --gulpfile "D:\Development\xxxx\WebSite\Gulpfile.js" build
[20:40:42] Using gulpfile D:\Development\xxxx\WebSite\Gulpfile.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:\Development\xxxx\WebSite\node_modules\gulp-tsb\lib\builder.js:153
        var newLastBuildVersion = new Map();
                                      ^
ReferenceError: Map is not defined
    at Object.build (D:\Development\xxxx\WebSite\node_modules\gulp-tsb\lib\builder.js:153:39)
    at Stream.<anonymous> (D:\Development\xxxx\WebSite\node_modules\gulp-tsb\lib\index.js:40:22)
    at _end (D:\Development\xxxx\WebSite\node_modules\through\index.js:65:9)
    at Stream.stream.end (D:\Development\xxxx\WebSite\node_modules\through\index.js:74:5)
    at DestroyableTransform.onend (D:\Development\xxxx\WebSite\node_modules\readable-stream\lib\_stream_readable.js:545:10)
    at DestroyableTransform.g (events.js:180:16)
    at DestroyableTransform.emit (events.js:117:20)
    at endReadableNT (D:\Development\xxxx\WebSite\node_modules\readable-stream\lib\_stream_readable.js:960:12)
Process terminated with code 8.
    at afterTick (D:\Development\xxxx\WebSite\node_modules\process-nextick-args\index.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资源管理器运行时,Gulp任务失败,但不能从命令提示符运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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