events.js:160 throw er; //未处理的'错误'事件

Hea*_*ang 25 javascript node.js node-modules gulp gulp-load-plugins

我工作的项目是用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||
Run Code Online (Sandbox Code Playgroud)

任务'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'));
});
Run Code Online (Sandbox Code Playgroud)

我google了很多,但我没有找到适合我的正确答案.

las*_*203 49

删除node_modules文件夹,清除npm缓存文件和执行全新安装,可以解决此问题.

rm -rf node_modules && npm cache clean --force && npm install
Run Code Online (Sandbox Code Playgroud)

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


小智 15

关于以下行的错误:

events.js:160
      throw er; // Unhandled 'error' event
Run Code Online (Sandbox Code Playgroud)

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

停止其他应用已解决此问题.

  • 这个问题非常头疼,这个答案来了,干杯! (5认同)

小智 6

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

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

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