paulmillr / readdirp

Recursive version of fs.readdir with streaming api.
https://paulmillr.com
MIT License
381 stars 52 forks source link

TypeError: require(...) is not a function #157

Closed swyxio closed 4 years ago

swyxio commented 4 years ago

I'm really not at all sure why this bug is happening, but when I run copy-template-dir (which uses readdirp) I get this:

/Users/swyx/Netlify/netlify-plugin-search-index/node_modules/copy-template-dir/node_modules/readdirp/readdirp.js:50
    var api          =  require('./stream-api')();
                                               ^

TypeError: require(...) is not a function
    at readdir (/Users/swyx/Netlify/netlify-plugin-search-index/node_modules/copy-template-dir/node_modules/readdirp/readdirp.js:50:48)
    at /Users/swyx/Netlify/netlify-plugin-search-index/node_modules/copy-template-dir/index.js:33:16
    at /Users/swyx/Netlify/netlify-plugin-search-index/node_modules/mkdirp/index.js:48:26
    at callback (/Users/swyx/Netlify/netlify-plugin-search-index/node_modules/graceful-fs/polyfills.js:295:20)
    at FSReqCallback.oncomplete (fs.js:167:5)
error Command failed with exit code 1.

I have checked and yes, stream-api.js is there, however what is unusual is that there are two module.exports that may be screwing things up:

module.exports = ReaddirpReadable;
function ReaddirpReadable (opts) {/* etc */}
function createStreamAPI () {/* etc */}
module.exports = createStreamAPI;

however commenting them out doesnt seem to help at all!

anyone have any idea what the cause of this could be?

paulmillr commented 4 years ago

Seems like you're using old version of readdirp. Update to latest.