browserify / watchify

watch mode for browserify builds
Other
1.79k stars 181 forks source link

TypeError: Cannot read property 'cache' of undefined #276

Closed Shurlow closed 9 years ago

Shurlow commented 9 years ago

Watchify is throwing this error when using with gulp and browserify.

Error occurs at line 14 var cache = b._options.cache;

I am using watchify identical to the example in the README does. This is all the code in my gulpfile as of now..

var b  = browserify(watchify.args);
var w = watchify(b)

I get the same error when passing the cache option directly to browserify as well.

Thoughts?

chippawah commented 7 years ago

@Shurlow What did you do to solve this? Currently getting this error as well.

Shurlow commented 7 years ago

@chippawah I ended up switching to webpack actually

But this is a snippet of my old gulp config that was working for me:

  var props = {
    entries: [scriptsDir + '/main.js'],
    extensions: ['.js', '.jsx'],
    debug : true,
    cache: {},
    packageCache: {},
    transform:  [babelify, looseEnvify, reactify]
  };

var bundler = watchify(browserify(props));
amalgamatedio commented 7 years ago

FWIW I started getting this error after a fresh npm install, and doing separate follow-up npm install browserify and npm install watchify fixed it. I did both before I tried again so it might have been one or the other or both that fixed it.

wioux commented 7 years ago

I followed @amalgamatedio's approach and the issue was fixed after npm install browserify (didn't need to separately install watchify).

gdsouza1992 commented 7 years ago

npm install browserify did it for me too 👍

bradisbell commented 5 years ago

The fix for me was to ensure I was using this package as a plugin and not as a transform.