S
S
Shakhrom Mukumov2018-10-25 16:37:21
Node.js
Shakhrom Mukumov, 2018-10-25 16:37:21

How to fix an error in Gulp?

Hello.
Please help me to fix the error.
I met Gulp recently, I set it up for myself on the video, everything worked until this morning.
Here is the error itself:

events.js:183
      throw er; // Unhandled 'error' event
      ^
SyntaxError: Unterminated string constant (12:44)
    at Parser.pp$4.raise (C:\Users\shakhrom\Desktop\Inweex\node_modules\acorn-globals\node_modules\acorn\dist\acorn.js:2488:13)
    at Parser.pp$7.readString (C:\Users\shakhrom\Desktop\Inweex\node_modules\acorn-globals\node_modules\acorn\dist\acorn.js:3195:33)
    at Parser.pp$7.getTokenFromCode (C:\Users\shakhrom\Desktop\Inweex\node_modules\acorn-globals\node_modules\acorn\dist\acorn.js:2980:17)
    at Parser.pp$7.readToken (C:\Users\shakhrom\Desktop\Inweex\node_modules\acorn-globals\node_modules\acorn\dist\acorn.js:2733:15)
    at Parser.pp$7.nextToken (C:\Users\shakhrom\Desktop\Inweex\node_modules\acorn-globals\node_modules\acorn\dist\acorn.js:2724:13)
    at Parser.pp$7.next (C:\Users\shakhrom\Desktop\Inweex\node_modules\acorn-globals\node_modules\acorn\dist\acorn.js:2684:8)
    at Parser.pp$3.parseLiteral (C:\Users\shakhrom\Desktop\Inweex\node_modules\acorn-globals\node_modules\acorn\dist\acorn.js:2019:8)
    at Parser.pp$3.parseExprAtom (C:\Users\shakhrom\Desktop\Inweex\node_modules\acorn-globals\node_modules\acorn\dist\acorn.js:1968:17)
    at Parser.pp$3.parseExprSubscripts (C:\Users\shakhrom\Desktop\Inweex\node_modules\acorn-globals\node_modules\acorn\dist\acorn.js:1872:19)
    at Parser.pp$3.parseMaybeUnary (C:\Users\shakhrom\Desktop\Inweex\node_modules\acorn-globals\node_modules\acorn\dist\acorn.js:1849:17)

And here is what is in the gulpfile.js file
var syntax        = 'sass'; // Syntax: sass or scss;

var 
  gulp          = require('gulp'),
  browserSync   = require('browser-sync'),
  sass          = require('gulp-sass'),
  concat        = require('gulp-concat'),
  uglify        = require('gulp-uglify'),
  cleancss      = require('gulp-clean-css'),
  groupmedia	  = require('gulp-group-css-media-queries'),
  rename        = require('gulp-rename'),
  del           = require('del'),
  imagemin      = require('gulp-imagemin'),
  pngquant      = require('imagemin-pngquant'),
  cache         = require('gulp-cache'),
  autoprefixer  = require('gulp-autoprefixer'),
  notify        = require("gulp-notify");
  pug           = require('gulp-pug' ),

gulp.task('browser-sync', function() {
  browserSync({
    server: {
      baseDir: 'app'
    },
    notify: false,
    // open: false,
    // online: false, // Work Offline Without Internet Connection
    // tunnel: true, tunnel: "demo", // Demonstration page: http://projectname.localtunnel.me
  })
});

gulp.task('pug', function buildHTML() {
  return gulp.src('app/pug/pages/*.pug')
  .pipe(pug({
    pretty: true
  }))
  .pipe(gulp.dest('app'))
});

gulp.task('styles', function() {
  return gulp.src('app/'+syntax+'/**/*.'+syntax+'')
  .pipe(sass({ outputStyle: 'expanded' }).on("error", notify.onError()))
  .pipe(rename({ suffix: '.min', prefix : '' }))
  .pipe(autoprefixer(['last 15 versions']))
  .pipe(groupmedia())
  .pipe(cleancss()) // Opt., comment out when debugging
  .pipe(gulp.dest('app/css'))
  .pipe(browserSync.reload({stream: true}))
});

gulp.task('js', function() {
  return gulp.src([
    'app/libs/jquery/jquery.min.js',
    'app/js/common.js', // Always at the end
    ])
  .pipe(concat('scripts.min.js'))
  // .pipe(uglify()) // Minify js (opt.)
  .pipe(gulp.dest('app/js'))
  .pipe(browserSync.reload({ stream: true }))
});

gulp.task('imagemin', function() {
  return gulp.src('app/img/**/*')
    .pipe(cache(imagemin({
      interlaced: true,
      progressive: true,
      svgoPlugins: [{removeViewBox: false}],
      use: [pngquant()]
    })))
    .pipe(gulp.dest('dist/img')); 
});

gulp.task('build', ['removedist', 'imagemin', 'styles', 'js'], function() {

  var buildFiles = gulp.src([
    'app/*.html',
    'app/*.php',
    'app/.htaccess',
    ]).pipe(gulp.dest('dist'));

  var buildCss = gulp.src([
    'app/css/main.min.css',
    ]).pipe(gulp.dest('dist/css'));

  var buildJs = gulp.src([
    'app/js/scripts.min.js',
    ]).pipe(gulp.dest('dist/js'));

  var buildFonts = gulp.src([
    'app/fonts/**/*',
    ]).pipe(gulp.dest('dist/fonts'));

});

gulp.task('watch', ['pug', 'styles', 'js', 'browser-sync'], function() {
  gulp.watch('app/'+syntax+'/**/*.'+syntax+'', ['styles']);
  gulp.watch('app/pug/**/*.pug', ['pug']);
  gulp.watch(['libs/**/*.js', 'app/js/common.js'], ['js']);
  gulp.watch('app/*.html', browserSync.reload)
});

gulp.task('removedist', function() { return del.sync('dist'); });
gulp.task('clearcache', function () { return cache.clearAll(); });
gulp.task('default', ['watch']);

The error comes out with watch , but there are no errors with gulp build .
Already completely removed node.js, cleaned all related directories.
  • Node v8.12.0
  • Gulp v3.9.1
  • NPM v6.4.1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shakhrom Mukumov, 2018-10-25
@leon9208

The error was in the .pug file, it's bad that the error is poorly readable in the console, for example, if you add an extra indent, it points to the error line, and here to the module.
I found an error by sorting through the tasks manually, everything worked except for the .pug task , it turned out that I added an extra QUOTE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question