Watchify
I'm using the browserify guide in this repo.
Here's watchify working fine by itself:
❯ watchify assets/js/monkey.js -o test.js -v
8439 bytes written to test.js (0.02 seconds)
8417 bytes written to test.js (0.01 seconds)
8420 bytes written to test.js (0.02 seconds)
8417 bytes written to test.js (0.01 seconds)
And here's my attempted gulp task:
gulp.task('js', function () {
var bundler = watchify(browserify('assets/js/monkey.js', watchify.args));
bundler.on('update', rebundle);
function rebundle() {
return bundler.bundle()
.on('error', console.log.bind(console, 'Browserify Error'))
.pipe(source('bundle.js'))
.pipe(gulp.dest('./assets/build'));
}
return rebundle();
});
However, when I run it (and it runs from the same directory as I ran the watchify command from before), I get an error:
Browserify Error { [Error: Cannot find module 'assets/js/monkey.js' from '/Users/callumacrae/Sites/lostmyname/monkey']
stream:
{ _readableState:
{ highWaterMark: 16,
buffer: [],
length: 0,
pipes: [Object],
pipesCount: 1,
flowing: true,
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
objectMode: true,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null,
resumeScheduled: false },
readable: true,
domain: null,
_events:
{ end: [Object],
error: [Object],
data: [Function: ondata],
_mutate: [Object] },
_maxListeners: 10,
_writableState:
{ highWaterMark: 16,
objectMode: true,
needDrain: false,
ending: true,
ended: true,
finished: true,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [],
pendingcb: 0,
prefinished: true,
errorEmitted: false },
writable: true,
allowHalfOpen: true,
_options: { objectMode: true },
_wrapOptions: { objectMode: true },
_streams: [ [Object] ],
length: 1,
label: 'deps' } }
Any ideas what could be causing this?