Javascript events.js:160 抛出 er; // 未处理的“错误”事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38841204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 21:55:42  来源:igfitidea点击:

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

javascriptnode.jsgulpnode-modulesgulp-load-plugins

提问by Heath Yang

The project I worked on was built with gulp.

我参与的项目是用 gulp 构建的。

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

最近我将节点版本更新到了 v6.3.1。然后出了点问题。

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

名为“html”的任务会引发错误。这是它的错误代码部分。

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':

和任务'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.

我用谷歌搜索了很多,但没有找到适合我的正确答案。

回答by lasec0203

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

删除 node_modules 文件夹、清除 npm 缓存文件并进行全新安装,即可解决此问题。

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

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

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

回答by user3379633

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.

停止其他应用程序解决了该问题。

回答by Anand Kapdi

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

我在 Ubuntu 上运行我的 create-react-app 时遇到了类似的错误,同时运行命令 npm start

It gets solved when I run sudo npm start

当我运行时它会解决 sudo npm start

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

我认为问题可能在于应用程序没有足够的权限。

回答by Heath Yang

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

最近,我将节点版本更改为 v5.10.0,一切都运行良好。

回答by Ilya Sviridenko

I had similar problem with events.js.

我对 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).

在我的情况下,出现问题是因为我忘记从我的 Gemfile 安装 gems(在完整的系统重新安装后)。

So, cure for me was:

所以,对我来说治愈是:

gem install jekyll

回答by BEJGAM SHIVA PRASAD

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

如果使用静态 IP,某些情况下 IP 地址也可能错误

回答by Artemiy Zajcev

Try to kill other gulp processes.

尝试杀死其他 gulp 进程。

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

回答by hazan kazim

events.js:160

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 .

  1. 使用另一个节点的端口,因此您可以从 server.js 更改节点的端口

    2.或停止其他应用程序使用相同的端口。

回答by Amitesh

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.

我在启动 laravel-echo-server npm 包时遇到了同样的错误。PFA 图像供参考。我想如果你因为任何 npm 包而出错,这个答案会对你有所帮助。

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.
  • 我的域没有正确配置。检查图像,我正在尝试访问 pid.contentcentral.co 域,该域已被禁用或未正确配置。因此抛出错误。更正配置并解决问题。

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.

  • 错误:在 Node.js 中监听 EADDRNOTAVAIL 错误

    当您错误地看到这一行时,不是端口而是您的 IP 地址/域遇到了一些问题。

  • 错误:听 EADDRINUSE

    当您错误地看到这一行时,不是您的 IP 地址/域,但肯定端口有一些问题可能已经在使用中。

回答by umer sayyed

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

在运行命令 npm start 时,我在 Ubuntu 上遇到了类似的错误

Running sudo npm start solved my problem

运行 sudo npm start 解决了我的问题

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

我认为这是因为文件夹没有摩根记录器的写权限。