copy-webpack-plugin: "Options should be array" error - constructor only takes array args.
- Operating System: Windows 10
- Node Version: 6.14.4
- NPM Version: 14.0.0
- webpack Version: 4.43.0
- copy-webpack-plugin Version: 5.1.1
Expected Behavior
It would be expected the documented syntax for the plugin works.
Actual Behavior
If the constructor is structured like the documentation, you get an error like this:
CopyPlugin Invalid Options
options should be array
ValidationError: CopyPlugin Invalid Options
at validateOptions (C:\Users\user\code\app\node_modules\copy-webpack-plugin\node_modules\schema-utils\src\validateOptions.js:32:11)
Code
Error-causing code:
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
plugins: [
new CopyPlugin({
patterns: [
{ from: 'source', to: 'dest' },
{ from: 'other', to: 'public' },
],
}),
],
};
Good code:
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
plugins: [
new CopyPlugin(
[
{ from: 'source', to: 'dest' },
{ from: 'other', to: 'public' },
]
),
],
};
How Do We Reproduce?
Create webpack config with documented syntax.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 104
- Comments: 16 (3 by maintainers)
Commits related to this issue
- CopyPlugin https://github.com/webpack-contrib/copy-webpack-plugin/issues/455 — committed to lychees/Re-0-Make-your-own-Roguelike-Game-with-TypeScript by lychees 4 years ago
- Update README.md Fix https://github.com/webpack-contrib/copy-webpack-plugin/issues/455 — committed to lunfel/copy-webpack-plugin by lunfel 4 years ago
- Webpack copy plugin error fix I was testing this plugin implementation and I got an "Options should be array" error. After investigation I found that the docs are wrong. See more here: https://gi... — committed to Callan003/partytown by Callan003 2 years ago
- docs: Webpack copy plugin error fix (#250) I was testing this plugin implementation and I got an "Options should be array" error. After investigation I found that the docs are wrong. See more her... — committed to BuilderIO/partytown by Callan003 2 years ago
I don’t know why this issue was closed - I searched the open issues because of this problem an hour ago, but only found this solution now. The issue is not resolved until the incorrect public documentation has been fixed. Until then, people are going to be trying to understand why this is not working and looking through your open issues and not finding this.
Short answer:
Long answer:
I can confirm I am having this problem as well.
I see from the git history that you just made a breaking change that hasn’t been released yet, but it’s frustrating and time consuming that I’m working with a freshly installed module and reading the official docs, but it doesn’t work as documented.
Perhaps release branches would reduce these issues.
It’s too much!!!,copy-webpack-plugin
5.1.1
isREADME.md is
https://webpack.js.org/plugins/copy-webpack-plugin/ is still showing the old syntax. gave up and googled. here I am. weird issue to have?
This should absolutely not be closed… This is clearly an issue and this ticket serves as a point of reference for people who have this problem. This should be closed once the change has been merged…
Oh man this just tripped me up for the last hour or so. I was about to downgrade to try and get around this. Thanks!
6 version was released https://github.com/webpack-contrib/copy-webpack-plugin/releases/tag/v6.0.0
I’m having the same issue. Please fix.
We have a next branch in master because we prepare next release, please use documentation from here https://github.com/webpack-contrib/copy-webpack-plugin/tree/v5.1.1, release will be soon