admin管理员组

文章数量:1202371

My WebStorm has stopped read and run gulp tasks.

It was working fine until last Friday.

This is an error that appears in console:

Failed to list gulp tasks in questionary/gulpfile.js: Failed to parse JSON -> Unterminated array at line 1 column 5 path $[1] * Edit settings

$ /usr/local/bin/node /Users/rkon2006/Projects/My/questionary/node_modules/gulp/bin/gulp.js --no-color --gulpfile /Users/rkon2006/Projects/My/questionary/gulpfile.js --tasks-json [17:26:14] Using gulpfile ~/Projects/My/questionary/gulpfile.js [17:26:14] Starting 'default'... Default task...

This is the code from my gulpfile.js (it doesn't start even with this code):

var gulp = require('gulp');

gulp.task('default', function () {
    console.log('Default task...');
});

My WebStorm has stopped read and run gulp tasks.

It was working fine until last Friday.

This is an error that appears in console:

Failed to list gulp tasks in questionary/gulpfile.js: Failed to parse JSON -> Unterminated array at line 1 column 5 path $[1] * Edit settings

$ /usr/local/bin/node /Users/rkon2006/Projects/My/questionary/node_modules/gulp/bin/gulp.js --no-color --gulpfile /Users/rkon2006/Projects/My/questionary/gulpfile.js --tasks-json [17:26:14] Using gulpfile ~/Projects/My/questionary/gulpfile.js [17:26:14] Starting 'default'... Default task...

This is the code from my gulpfile.js (it doesn't start even with this code):

var gulp = require('gulp');

gulp.task('default', function () {
    console.log('Default task...');
});

Process finished with exit code 0

I use gulp v4.0, node js 4.1.1 (tried defferent versions from 0.10.28 up to 4.1.1) and npm 2.14.4.

Do you have any ideas about this?

Share Improve this question edited Sep 28, 2015 at 14:59 Priyesh 2,0711 gold badge18 silver badges26 bronze badges asked Sep 28, 2015 at 14:33 Роман КононихинРоман Кононихин 511 silver badge3 bronze badges
Add a comment  | 

4 Answers 4

Reset to default 18

I have the same problem with webstorm after install a updated version of node. The solution for me is the following:

In the block Gulp where webstorm show the list of task, click the cog icon and select gulp settings, in the section "Gulp package" add the path to the local gulp package(the gulp inside the node_modules in your project).

Example of path: yourproject\node_modules\gulp

Update node version and npm itself, that did the trick.

The problem is that some text is logged to standard output stream when evaluating gulpfile.js, but before running any gulp task (i.e. logging happens outside of gulp tasks); possible workarounds:

  • Avoid logging anything to standard output stream outside of gulp tasks.

Or

  • Don't log to standard output stream if it's started for listing tasks, like:
if (!isListingTasks()) {
    console.log('[my info]');
}

function isListingTasks() {
    return process.argv[process.argv.length - 1] === '--tasks-json';
}

I was having same problem and it was fixed by selecting different Node Interpreter version e.g. in the below image I selected 8.9.2 and then clicked small refresh button in Gulp window and the issue was fixed.

本文标签: javascriptGulp error in WebStorm Failed to list gulp tasksStack Overflow