Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error, if use stream and empty file #219

Open
vitstr opened this issue Oct 26, 2015 · 10 comments
Open

Error, if use stream and empty file #219

vitstr opened this issue Oct 26, 2015 · 10 comments

Comments

@vitstr
Copy link

vitstr commented Oct 26, 2015

Hi, guys!

I'm use:

  • node v4.2.1
  • gulp 3.9.0
  • wiredep 2.2.2

I have two scss file in 'app/assets/styles/' folder. One file is empty.
If run this code, wiredep return error.

var gulp = require('gulp');
var gulpLoadPlugins = require('gulp-load-plugins');
var wiredepGulp = require('wiredep').stream;
var $ = gulpLoadPlugins();

gulp.task('wiredep', function () {
    return gulp.src('app/assets/styles/*.scss', {base: 'src'})
        .pipe(wiredepGulp())
        .pipe(gulp.dest('app'));
});

Error text:

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

TypeError: must start with number, buffer, array or string
    at fromObject (buffer.js:167:9)
    at new Buffer (buffer.js:58:10)
    at DestroyableTransform._transform (/Users/xxx/ownCloud/Projects/base-layouts/node_modules/wiredep/wiredep.js:135:23)
    at DestroyableTransform.Transform._read (/Users/xxx/ownCloud/Projects/base-layouts/node_modules/wiredep/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/Users/xxx/ownCloud/Projects/base-layouts/node_modules/wiredep/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/Users/xxx/ownCloud/Projects/base-layouts/node_modules/wiredep/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/Users/xxx/ownCloud/Projects/base-layouts/node_modules/wiredep/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at DestroyableTransform.Writable.write (/Users/xxx/ownCloud/Projects/base-layouts/node_modules/wiredep/node_modules/readable-stream/lib/_stream_writable.js:194:11)
    at DestroyableTransform.ondata (/Users/xxx/ownCloud/Projects/base-layouts/node_modules/readable-stream/lib/_stream_readable.js:578:20)
    at emitOne (events.js:77:13)

but, if run this code (without gulp stream), build is successful

gulp.task('wiredep', function () {
    require('wiredep')({
        src: 'app/assets/styles/*.scss'
    });
});

It is bug or feature?) Thanks.

@zfarrugia
Copy link

Im having a similar/same issue:

node -v :: v5.0.0
gulp -v :: 3.9.0
wiredep :: 2.2.2

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

Error: Error: angular is not installed. Try running bower install.
at /Users/zac/PhpstormProjects/myApp/node_modules/wiredep/wiredep.js:30:56
at /Users/zac/PhpstormProjects/myApp/node_modules/wiredep/lib/detect-dependencies.js:145:29
at forOwn (/Users/zac/PhpstormProjects/myApp/node_modules/wiredep/node_modules/lodash/dist/lodash.js:2106:15)
at Function.forEach (/Users/zac/PhpstormProjects/myApp/node_modules/wiredep/node_modules/lodash/dist/lodash.js:3303:9)
at detectDependencies (/Users/zac/PhpstormProjects/myApp/node_modules/wiredep/lib/detect-dependencies.js:34:7)
at wiredep (/Users/zac/PhpstormProjects/myApp/node_modules/wiredep/wiredep.js:70:39)
at DestroyableTransform._transform (/Users/zac/PhpstormProjects/myApp/node_modules/wiredep/wiredep.js:135:34)
at DestroyableTransform.Transform._read (/Users/zac/PhpstormProjects/myApp/node_modules/wiredep/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/Users/zac/PhpstormProjects/myApp/node_modules/wiredep/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/Users/zac/PhpstormProjects/myApp/node_modules/wiredep/node_modules/readable-stream/lib/_stream_writable.js:237:10)

@corin12355
Copy link

Same issue here

gulp -v
CLI version = 0.3.0
Local version = 3.9.0

node -v = v5.0.0

wiredep = 3.0.0-beta

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

TypeError: must start with number, buffer, array or string
at fromObject (buffer.js:167:9)
at new Buffer (buffer.js:58:10)
at DestroyableTransform._transform (/home/sgw/public_html/sag/node_modules/wiredep/wiredep.js:135:23)
at DestroyableTransform.Transform._read (/home/sgw/public_html/sag/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/home/sgw/public_html/sag/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/home/sgw/public_html/sag/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/home/sgw/public_html/sag/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at DestroyableTransform.Writable.write (/home/sgw/public_html/sag/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at write (/home/sgw/public_html/sag/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/sgw/public_html/sag/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)

@baerkins
Copy link

baerkins commented Dec 8, 2015

Same exact thing as @corin12355 (same versions and all)

@brousalis
Copy link

The fix can be made in wiredep.js line 130:

opts.stream = {
   src: file.contents.toString() || "",

it tries to load the stream with undefined because the file is blank, which causes the TypeError.

@corin12355
Copy link

@iamhexcoder I found a fix, basically if a file is empty then it'll error out with a non-descriptive error.
Just check your manifest for empty files.

@coldkite
Copy link

agree with @brousalis
actually it could be anything except null or empty string
so, || "" not works. something like || " " works

@akleiber
Copy link

quickfix https://www.npmjs.com/package/gulp-clip-empty-files

@mbjacket81
Copy link

I like your solution akleiber but coldkite's solution worked for me as well. Thanks!

@eddiemonge
Copy link
Contributor

PRs welcome

@dmishh
Copy link

dmishh commented Oct 21, 2016

Got the same issue with an empty Google Analytics verification html file. Added one space to it as a temporary solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants