what is the reason of " events.js:174 throw er; // Unhandled 'error' event " gulp error message?

1.2k views Asked by At

I'm tryig to write a code that test another functionality code using jasmine testing framework and gulp But i'm new in the Gulp field and i'm encountering the following issue my code is :

/*eslint-env node */

const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const eslint = require('gulp-eslint');
const jasmineBrowser = require('gulp-jasmine-browser');


gulp.task('default', ['styles', 'lint'], function() {
    gulp.watch('sass/**/*.scss', ['styles']);
    gulp.watch('js/**/*.js', ['lint']);

    browserSync.init({
        server: './'
    });
});

gulp.task('styles', function() {
    gulp
        .src('sass/**/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(
            autoprefixer({
                browsers: ['last 2 versions']
            })
        )
        .pipe(gulp.dest('./css'))
        .pipe(browserSync.stream());
});

gulp.task('lint', function() {
    return (
        gulp
            .src(['js/**/*.js'])
            // eslint() attaches the lint output to the eslint property
            // of the file object so it can be used by other modules.
            .pipe(eslint())
            // eslint.format() outputs the lint results to the console.
            // Alternatively use eslint.formatEach() (see Docs).
            .pipe(eslint.format())
            // To have the process exit with an error code (1) on
            // lint error, return the stream and pipe to failOnError last.
            .pipe(eslint.failOnError())
    );
});

gulp.task('tests', function() {
    return gulp
        .src('tests/spec/extraSpec.js')
        .pipe(jasmineBrowser.specRunner({ console: true }))

        .pipe(jasmineBrowser.headless({ driver: 'chrome' }));
});

And when i execute the following command in the terminal gulp tests I get this error message

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\atlas\Desktop\ud892\Lesson 2\node_modules\gulp-jasmine-browser\lib\runners\chrome_runner ENOENT

what is the reason of this issue? and how can i solve it? Taking into consideration that i'm using windows7 and , i have read all the relevant stackoverflow posts but neither of them has the answer.

1

There are 1 answers

0
Lix On BEST ANSWER

When you don't create a variable with var/let/const it is created as a global variable in the global scope and it will be accessible from anywhere in your code.

If you were to use strict mode, using an uninitialised variable (as you have done above) would result in a ReferenceError error since it does not yet exist.