'Gulpfile.js - failed to load See output' but output does not show any error information

柔情痞子 提交于 2020-01-25 09:04:48

问题


I am trying to use gulp to copy some JS/CSS from node_modules to wwwroot in an ASP.Net core app.

I have what I thought was a fairly simple gulpfile.js

var gulp = require('gulp');
gulp.task('copy-files', function () {
    var assets = {
        js: [
            './node_modules/bootstrap/dist/js/bootstrap.js'
        ],
        css: [
            './node_modules/bootstrap/dist/css/bootstrap.css'
        ]
    };
    _(assets).forEach(function (assets, type) {
        gulp.src(assets).pipe(gulp.dest('./wwwroot/' + type));
    });
});

However, when I look at the VS Task Runner, it just shows an error:

But the output window is empty:

How can I get more information about the error?


回答1:


The problem is not related to path, but actually there must be some problem with gulp file itself either syntax error or some package is missing which unfortunately visual studio does not show that specific error but generic error what you see in task runner "failed to load". And the right way to see the errors is

  1. Open the command prompt (preferably in admin mode, this is what i did).
  2. Goto the same location where gulp file is located.
  3. Run the task through following command example --> gulp default
  4. If there is any error like package is missing, it will show you, fix those issues.
  5. After all errors are fixed, then you will see that gulp task runs successfully.
  6. Go back to visual studio, task runner, and click on refresh (left top button), and it will show you all tasks.

screenshot?




回答2:


This answer here worked for me.

Moved up the $(PATH) location above everything. As I did not have (DevEnvDir)|Extensions\Microsoft\Web Tools\External location as mentioned in the answer.

For VS 2015

Tools > Options > Projects and Solutions > External Web Tools

For VS 2017

Tools > Options > Projects and Solutions > Web Package Management > External Web Tools




回答3:


I'm not sure why but opening a cmd prompt at the directory containing gulpfile.js and running npm install has fixed it.

Perhaps someone wiser than I can explain why.




回答4:


In Output window, make sure you select Task Runner Explorer for Show output from option. This was my problem why I didn't see the error logs from gulpfile. A rookie mistake.



来源:https://stackoverflow.com/questions/47446120/gulpfile-js-failed-to-load-see-output-but-output-does-not-show-any-error-inf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!