Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Js Syntax Error in plugin 'gulp-browserify' while running Gulp Tasks

I'm running a Node App project built on Express, Jade and Less. I'm using 'Gulp' (The streaming build system) along with 'browserify' and 'gulp-browserify'. But when I run Gulp Task its throwing error showing like

[gulp] SyntaxError in plugin 'gulp-browserify': <my_project_path>/assets/javascripts/fake_a3100e75.js 

The file fake_a3100e75.js does not seem to exists in directory.

Has anybody come across the same problem? Any solutions highly appreciated?

like image 285
Prasad Avatar asked Feb 27 '14 06:02

Prasad


1 Answers

gulp-browserify isn't a recommended plugin. Its actually blacklisted. This is because Browserify handles its own I/O operations and returns a stream itself, so there's no need for gulp.src(). Instead use Browserify or Watchify directly along with vinyl-source-stream to stream it into other plugins. There's a recipe in the docs here.

There's also a good recipe for handling errors.

Here's what the task I'm working on looks like right now.

Your error pointed to a fake filename because that's what gulp-browserify names the file in a vinyl stream. With the recipes above you name the file yourself with vinyl-source-stream, and that's after the error handler is set on browserify, so you should get proper browserify errors.

like image 151
DSKrepps Avatar answered Oct 17 '22 04:10

DSKrepps