【问题标题】:events.js:160 throw er; // Unhandled 'error' eventevents.js:160 抛出 er; // 未处理的“错误”事件
【发布时间】:2016-12-14 22:29:08
【问题描述】:

我从事的项目是用 gulp 构建的。

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

名为“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||

以及任务'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'));
});

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

【问题讨论】:

标签: javascript node.js gulp node-modules gulp-load-plugins


【解决方案1】:

最近,我将节点版本更改为 v5.10.0,一切正常。

【讨论】:

    【解决方案2】:

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

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

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

    【讨论】:

    • 对我来说,它需要在我重新启动计算机后始终清除。有什么办法可以避免这个问题?
    【解决方案3】:

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

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

    所以,治疗我的是:

    gem install jekyll
    

    【讨论】:

      【解决方案4】:

      在我的情况下,端口已经在使用中..

      # netstat -nltp
      

      检查是否有任何正在尝试启动的端口运行..如果是,请更改端口并尝试。

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

      【讨论】:

        【解决方案5】:

        关于以下行的错误:

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

        对我来说,问题是我已经在另一个本地节点应用程序上打开了端口。

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

        【讨论】:

        • 这个问题非常头疼,这个答案通过了,干杯!
        【解决方案6】:

        尝试杀死其他 gulp 进程。

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

        【讨论】:

          【解决方案7】:

          events.js:160

          这是因为

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

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

          【讨论】:

            【解决方案8】:

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

            我是如何找到解决方案的:

            • 我的域配置不正确。检查图像,我正在尝试访问已禁用或未正确配置的 pid.contentcentral.co 域。因此抛出错误。更正配置并解决问题。

            其他要点:

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

              当您看到此行错误时,不是端口,而是您的 IP 地址/域肯定有问题。

            • 错误:监听 EADDRINUSE

              当您看到此行错误时,不是您的 IP 地址/域,而是端口出现问题,可能已经在使用中。

            【讨论】:

            • 请添加一些代码,以便其他用户可以测试您所描述的内容。谢谢!
            【解决方案9】:

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

            当我运行sudo npm start时它得到了解决

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

            【讨论】:

            • 就我而言,这是在重命名由create-app cmd 创建的原始文件夹之后发生的。需要记住的一点。
            【解决方案10】:

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

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

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

            【讨论】:

              【解决方案11】:

              解决方案: $event => 只能用于 .ts 文件。

               $scope.openFromCalendar = ($event) => {
                      $event.preventDefault();
                      $event.stopPropagation();
              
                      $scope.fromCalendarOpened = true;
                      $scope.ToCalendarOpened = false;
                  };
              

              如果您使用的是 .js 文件,请像这样使用它

              $scope.openFromCalendar = function ($event) {
                              $event.preventDefault();
                              $event.stopPropagation();
                              $scope.fromCalendarOpened = true;
                              $scope.ToCalendarOpened = false;
                          };
              

              【讨论】:

              【解决方案12】:

              尝试运行以下命令,然后执行您想要执行的操作

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

              我希望它会起作用。

              【讨论】:

                【解决方案13】:

                设置环境变量 windows/system32
                它适用于窗户

                【讨论】:

                • 如有必要,请提供所有步骤的解决方案。
                猜你喜欢
                • 2017-05-06
                • 1970-01-01
                • 2019-11-10
                • 2020-01-16
                • 2019-01-08
                • 2019-05-04
                • 2018-10-03
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多