Roots Discourse

Webpack Yarn Build Error Related to copy-globs-webpack-plugin

Hi all,

I have a webpack install of the Sage WordPress theme and can’t get around this error after running yarn run build:

$ yarn run build
yarn run v1.17.3
$ webpack --progress --config resources/assets/build/webpack.config.js
10% building 2/2 modules 0 active(node:56972) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
98% after emitting bound afterEmitHandler/Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/copy-globs-webpack-plugin/index.js:129
                                Object.keys(this.files).filter(absoluteFrom => !compilation.fileDependencies.includes(absoluteFrom)).forEach(absoluteFrom => compilation.fileDependencies.push(absoluteFrom));
                                                                                                             ^

TypeError: compilation.fileDependencies.includes is not a function
    at Object.keys.filter.absoluteFrom (/Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/copy-globs-webpack-plugin/index.js:129:82)
    at Array.filter (<anonymous>)
    at module.exports.afterEmitHandler (/Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/copy-globs-webpack-plugin/index.js:129:29)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/tapable/lib/Hook.js:154:20)
    at asyncLib.forEachLimit.err (/Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/webpack/lib/Compiler.js:472:27)
    at /Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/neo-async/async.js:2818:7
    at done (/Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/neo-async/async.js:3522:9)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at outputFileSystem.writeFile.err (/Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/webpack/lib/Compiler.js:454:33)
    at /Users/chrisheuberger/_RadishLab/AFI001/app/themes/afi/node_modules/graceful-fs/graceful-fs.js:57:14
    at FSReqWrap.oncomplete (fs.js:141:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The only other related thread I can find is this Resources > Assets > Images TypeError: compilation.fileDependencies.has is not a function (copy-globs-webpack-plugin) yarn not working but in my package.json, the dependency already has the suggested version: "copy-globs-webpack-plugin": "^0.2.0", I tried removing node_modules and package-lock.json and re-running yarn run build but no dice.

My enviroment:
Mac OS 10.14.6
Node 10.12.0
Yarn 1.17.3
webpack 4.39.2
PHP 7.3.8

Thanks!

Aha, I think I solved it based on this thread which I only just saw: Yarn:build problem - copy-globs-webpack-plugin throwing error ... HELP?!

I was able to update the offending dependency by running

yarn add copy-globs-webpack-plugin@0.3.0 --dev

Then I was able to run yarn run build again without error. I apologize for the duplicate thread!