# Copy-webpack-plugin causes build failure on netlify

**URL:** <https://answers.netlify.com/t/copy-webpack-plugin-causes-build-failure-on-netlify/54862>\
**Category:** Support\
**Tags:** building\
**Created:** [April 12, 2022, 1:10pm UTC](https://answers.netlify.com/t/copy-webpack-plugin-causes-build-failure-on-netlify/54862 "2022-04-12T13:10:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![igor.chodelka](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/igor.chodelka/32/36134_2.png) [@igor.chodelka](https://answers.netlify.com/u/igor.chodelka)\
**Post date:** [April 12, 2022, 1:10pm UTC](https://answers.netlify.com/t/copy-webpack-plugin-causes-build-failure-on-netlify/54862/1 "2022-04-12T13:10:36Z")

</div>

### Describe the bug

Adding copy-webpack-plugin causes build failure in netlify.  
**They use import() to load ESM dependencies, looks like your env is not supported it**

When I run build on my local machine or even in gitlab ci pipeline everything worked fine.

### Steps to reproduce

```auto
When running webpack build, it fails on:
8:55:20 PM: $ npm run build
8:55:20 PM: > webpack-test@1.0.0 build /opt/build/repo
8:55:20 PM: > webpack --mode production
8:55:31 PM: (node:3235) ExperimentalWarning: The ESM module loader is experimental.
8:55:31 PM: [webpack-cli] HookWebpackError: Only file and data URLs are supported by the default ESM loader
8:55:31 PM: at makeWebpackError (/opt/build/repo/node_modules/webpack/lib/HookWebpackError.js:48:9)
8:55:31 PM: at /opt/build/repo/node_modules/webpack/lib/Compilation.js:3059:12
8:55:31 PM: at eval (eval at create (/opt/build/repo/node_modules/tapable/lib/HookCodeFactory.js:33:10), :78:1)
8:55:31 PM: at /opt/build/repo/node_modules/webpack/lib/Compilation.js:510:26
8:55:31 PM: at /opt/build/repo/node_modules/copy-webpack-plugin/dist/index.js:708:13
8:55:31 PM: -- inner error --
8:55:31 PM: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader
8:55:31 PM: at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:720:11)
8:55:31 PM: at Loader.resolve (internal/modules/esm/loader.js:97:40)
8:55:31 PM: at Loader.getModuleJob (internal/modules/esm/loader.js:243:28)
8:55:31 PM: at ModuleWrap. (internal/modules/esm/module_job.js:42:40)
8:55:31 PM: at link (internal/modules/esm/module_job.js:41:36)
8:55:31 PM: caused by plugins in Compilation.hooks.processAssets
8:55:31 PM: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader
8:55:31 PM: at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:720:11)
8:55:31 PM: at Loader.resolve (internal/modules/esm/loader.js:97:40)
8:55:31 PM: at Loader.getModuleJob (internal/modules/esm/loader.js:243:28)
8:55:31 PM: at ModuleWrap. (internal/modules/esm/module_job.js:42:40)
8:55:31 PM: at link (internal/modules/esm/module_job.js:41:36)

```

### Environment

```auto
System:
OS: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
Memory: 17.37 GB / 31.78 GB
Binaries:
Node: 14.17.4 - C:\Program Files\nodejs\node.EXE
npm: 6.14.14 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (100.0.1185.36)
Internet Explorer: 11.0.19041.1566
Packages:
babel-loader: ^8.2.4 => 8.2.4
clean-webpack-plugin: ^4.0.0 => 4.0.0
css-loader: ^6.7.1 => 6.7.1
html-webpack-plugin: ^5.5.0 => 5.5.0
postcss-loader: ^6.2.1 => 6.2.1
style-loader: ^3.3.1 => 3.3.1
ts-loader: ^9.2.8 => 9.2.8
webpack: ^5.70.0 => 5.72.0
webpack-bundle-analyzer: ^4.5.0 => 4.5.0
webpack-cli: ^4.9.2 => 4.9.2
webpack-dev-server: ^4.7.4 => 4.8.1
copy-webpack-plugin: ^10.2.4 => 10.2.4

```

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [April 14, 2022, 9:18pm UTC](https://answers.netlify.com/t/copy-webpack-plugin-causes-build-failure-on-netlify/54862/2 "2022-04-14T21:18:53Z")

</div>

Hey there, @igor.chodelka 👋

Thanks for reaching out! Sorry to hear you are encountering difficulties. Can you please share your netlify site name where this is happening?

---

<div class="post-metadata">

**Author:** ![igor.chodelka](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/igor.chodelka/32/36134_2.png) [@igor.chodelka](https://answers.netlify.com/u/igor.chodelka)\
**Post date:** [April 25, 2022, 12:16pm UTC](https://answers.netlify.com/t/copy-webpack-plugin-causes-build-failure-on-netlify/54862/3 "2022-04-25T12:16:28Z")

</div>

Hello, yes, site name is: betbot

---

<div class="post-metadata">

**Author:** ![fool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fool/32/37_2.png) [@fool](https://answers.netlify.com/u/fool)\
**Post date:** [April 26, 2022, 8:43pm UTC](https://answers.netlify.com/t/copy-webpack-plugin-causes-build-failure-on-netlify/54862/4 "2022-04-26T20:43:29Z")

</div>

Seems like you managed to work around this, or anyway, your builds have succeeded since approximately when you opened this case.

I considered filing a bug on this, but I didn’t think I could speak well to your use case since I don’t understand much about the different ways of loading modules - would you mind opening one for our team at the URL below?

> **[Build software better, together](https://github.com/netlify/build-image/issues/new?assignees=&labels=type%3A%2Bbug&template=bug_report.md&title=Please%2Breplace%2Bwith%2Ba%2Bclear%2Band%2Bdescriptive%2Btitle)**
>
> GitHub is where people build software. More than 94 million people use GitHub to discover, fork, and contribute to over 330 million projects.

If you do mind, I can take a shot at it for you, but I might misspeak.

---

<div class="post-metadata">

**Author:** ![igor.chodelka](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/igor.chodelka/32/36134_2.png) [@igor.chodelka](https://answers.netlify.com/u/igor.chodelka)\
**Post date:** [April 29, 2022, 10:46am UTC](https://answers.netlify.com/t/copy-webpack-plugin-causes-build-failure-on-netlify/54862/5 "2022-04-29T10:46:17Z")

</div>

I did not manage to fix this bug. I just removed plugin so my site can build. But this is not what I wanted.  
I already reported this bug here. [copy-webpack-plugin causes build failure · Issue #4260 · netlify/build · GitHub](https://github.com/netlify/build/issues/4260)  
Feel free to copy paste.

Thanks

---

<div class="post-metadata">

**Author:** ![perry](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/perry/32/16_2.png) [@perry](https://answers.netlify.com/u/perry)\
**Post date:** [April 29, 2022, 4:04pm UTC](https://answers.netlify.com/t/copy-webpack-plugin-causes-build-failure-on-netlify/54862/6 "2022-04-29T16:04:23Z")

</div>

thank you igor, that will do just fine! appreciate it. Please keep an eye on that GH issue as we’ll update that as we work on this.
