32

The project I worked on was built with gulp.

Recently I updated the node version to v6.3.1. Then something came wrong.

A task named 'html' throws an error. Here is the part of error code of it.

bogon:toClient work$ gulp html
(node:2519) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

[10:26:10] Using gulpfile ~/Project/TIME_Cancer_Treatment_Centers_of_America(CTCA)/toClient/gulpfile.js
[10:26:10] Starting 'html'...
(node:2519) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: CSS parse error scripts/vendor.js: Unexpected input
    1 |!function(t,e){"object"==typeof module&&"object"==typeof module.exports?module.exports=t.document?e(t,!0):function(t){if(!t.document)throw new Error("jQuery requires a window with a document");return e(t)}:e(t)}("undefined"!=typeof window?window:this,function(t,e){function i(t){var e="length"in t&&t.length,i=J.type(t);return"function"!==i&&!J.isWindow(t)&&(!(1!==t.nodeType||!e)||("array"===i||0===e||

And the code of task 'html':

var $ = require('gulp-load-plugins')();

gulp.task('html', function() {
  var assets = $.useref.assets({searchPath: ['.tmp']});

  return gulp.src('app/*.html')
    .pipe(assets)
    .pipe($.if('*.js', $.uglify()))
    .pipe($.if('*.css', $.csso()))
    .pipe(assets.restore())
    .pipe($.useref())
    .pipe($.if('*.html', $.minifyHtml({conditionals: true, loose: true})))
    .pipe(gulp.dest('dist'));
});

I googled a lot but I haven't found a proper answer suitable for me.

Laurel
  • 5,965
  • 14
  • 31
  • 57
Heath Yang
  • 471
  • 1
  • 4
  • 10
  • 2
    Possible duplicate of [Node.js – events js 72 throw er unhandled 'error' event](http://stackoverflow.com/questions/22960703/node-js-events-js-72-throw-er-unhandled-error-event) – Jonny Henly Aug 09 '16 at 02:43
  • https://stackoverflow.com/questions/51630227/events-js167-throw-er-unhandled-error-event – Dinesh Naik Mar 06 '20 at 05:31

13 Answers13

65

removing the node_modules folder, clearing npm cached files, and doing a fresh install, resolves this issue.

rm -rf node_modules && npm cache clean --force && npm install

source: https://github.com/ember-cli/ember-cli/issues/3087#issuecomment-71327402

lasec0203
  • 2,422
  • 1
  • 21
  • 36
16

Regarding the error at the following line:

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

The issue for me was that I already had the port open on another local node app.

Stopping the other app resolved the issue.

QuietCoder
  • 161
  • 1
  • 4
6

I was facing similar error while running my create-react-app on Ubuntu, while running a command npm start

It gets solved when I run sudo npm start

I think a problem might be with application not having enough permissions.

Anand Kapdi
  • 491
  • 5
  • 4
  • In my case, that happened after renaming the original folder create by the `create-app` cmd. Something to keep in mind. – Btc Sources Feb 04 '20 at 09:54
2

Lately, I changed the node version to v5.10.0 and everything just acted well.

Heath Yang
  • 471
  • 1
  • 4
  • 10
2

Try to kill other gulp processes.

ps -ax | grep gulp
kill -9 <number>
1

I had similar problem with events.js.

[19:59:06] Starting 'jekyll-async'...

events.js:72
    throw er; // Unhandled 'error' event
          ^
Error: spawn ENOENT
    at errnoException (child_process.js:1011:11)
    at Process.ChildProcess._handle.onexit (child_process.js:802:34)

In my case problem occurred because I forgot to install gems from my Gemfile (after complete system reinstall).

So, cure for me was:

gem install jekyll
Ilya Sviridenko
  • 394
  • 3
  • 6
1

In my case the port already in use..

# netstat -nltp

Check is there any thing running with port which are trying to start with..if yes change port and try.

Some cases IP address also may wrong if using static IP

veganaiZe
  • 539
  • 5
  • 13
BEJGAM SHIVA PRASAD
  • 2,181
  • 1
  • 18
  • 27
1

events.js:160

This is because

  1. The port using another node so you change the port of node from server.js

    2.or stop the other app use the same port .

hazan kazim
  • 938
  • 9
  • 11
1

I was getting the same error while starting laravel-echo-server npm package. PFA image for reference. I think if you are getting error beacuse of any npm package this answer will be helpful to you.

enter image description here

How I found solution :

  • My domain was not properly configured. Check in the image, I'm trying to hit pid.contentcentral.co domain, which was disabled or not properly configured. Hence throws the error. Correction in the configuration and issue resolved.

Other Important points :

  • Error: listen EADDRNOTAVAIL error in Node.js

    When you see this line in error not the port but definitely your IP Address / Domain has got some trouble.

  • Error: listen EADDRINUSE

    When you see this line in error not your IP Address / Domain but definitely port has got some trouble may be already in use.

Community
  • 1
  • 1
Amitesh Bharti
  • 14,264
  • 6
  • 62
  • 62
1

I was facing similar error on Ubuntu, while running a command npm start

Running sudo npm start solved my problem

I think this is because folder doesn't have write permission for Morgan logger.

0

Solution: $event => can be used only .ts files.

 $scope.openFromCalendar = ($event) => {
        $event.preventDefault();
        $event.stopPropagation();

        $scope.fromCalendarOpened = true;
        $scope.ToCalendarOpened = false;
    };

If you are using .js files use it like

$scope.openFromCalendar = function ($event) {
                $event.preventDefault();
                $event.stopPropagation();
                $scope.fromCalendarOpened = true;
                $scope.ToCalendarOpened = false;
            };
  • 1
    This does not provide an answer to the question. You can [search for similar questions](https://stackoverflow.com/search), or refer to the related and linked questions on the right-hand side of the page to find an answer. If you have a related but different question, [ask a new question](https://stackoverflow.com/questions/ask), and include a link to this one to help provide context. See: [Ask questions, get answers, no distractions](https://stackoverflow.com/tour) – Stefan Becker Feb 06 '19 at 09:59
0

Try running following command and after that perform your action, you want to perform

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

I hope it will work.

Shahrukh Anwar
  • 2,544
  • 1
  • 24
  • 24
0

set env var windows/system32
it will work for windows