问题
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
- Open the command prompt (preferably in admin mode, this is what i did).
- Goto the same location where gulp file is located.
- Run the task through following command example --> gulp default
- If there is any error like package is missing, it will show you, fix those issues.
- After all errors are fixed, then you will see that gulp task runs successfully.
- 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