javascript的Gulp问题

时间:2019-02-25 14:25:35

标签: javascript gulp gulp-uglify

正如标题所述,我目前在项目中使用gulp。每次我尝试编译整个过程时,都会向我抛出错误。我遍历了代码,它似乎没有问题(而且最重要的是它起作用了)。当我从代码中删除单个函数时,它将对其进行编译而没有任何问题。

/* Main JS */

$(document).ready(function() {
  $.ajax({
    url: "resources/json/main-nav.json",
    method: "GET",
    type: "JSON",
    success: function(data){
      loadNav(data);
    }
  });
});

/* Functions NOTE: WHEN I REMOVE THIS FUNCTION, IT COMPILES WITHOUT ISSUES.*/
function loadNav(items){
  let writeNav = "";
  for(let item of items){
    writeNav += `<li><a href="${item.href}">${item.text}</a></li>`;
  }
  $(".navigation-list").html(writeNav);
}

编辑: 忘记了实际错误:

events.js:183
      throw er; // Unhandled 'error' event
      ^
GulpUglifyError: unable to minify JavaScript
    at createError (/var/www/html/guitar-store/node_modules/gulp-uglify/lib/create-error.js:6:14)
    at apply (/var/www/html/guitar-store/node_modules/gulp-uglify/node_modules/lodash/_apply.js:16:25)
    at wrapper (/var/www/html/guitar-store/node_modules/gulp-uglify/node_modules/lodash/_createCurry.js:41:12)
    at /var/www/html/guitar-store/node_modules/gulp-uglify/lib/minify.js:55:15
    at DestroyableTransform._transform (/var/www/html/guitar-store/node_modules/gulp-uglify/composer.js:12:19)
    at DestroyableTransform.Transform._read (/var/www/html/guitar-store/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/var/www/html/guitar-store/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:83)
    at doWrite (/var/www/html/guitar-store/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:428:64)
    at writeOrBuffer (/var/www/html/guitar-store/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:417:5)
    at DestroyableTransform.Writable.write (/var/www/html/guitar-store/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:334:11)

0 个答案:

没有答案