首页 > 解决方案 > ValidationError:无效的选项对象。Copy Plugin 已使用与 API 模式不匹配的选项对象进行初始化

问题描述

由于漏洞,我刚刚更新了 package.json 中的一些包。所有漏洞均已修复,但我执行 npm run 时出现以下错误。复制插件包在我的漏洞修复期间得到了更新。

我尝试从较旧的提交中复制 package.json 并重新安装所有包,但随后漏洞再次出现。

ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
 - options[0] misses the property 'patterns'. Should be:
   [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
 - options[1] misses the property 'patterns'. Should be:
   [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)

标签: vue.jsnpm

解决方案


对于配置问题:

在 webpack.common.js 中修改以下部分:

module.exports = {
  plugins: [
    new CopyWebpackPlugin({
      patterns: [
        { from: Path.resolve('./modules/web/static/'), to: './assets' },
        { from: Path.resolve('./modules/web/static/favicon.ico'), to: './' },
      ]
    }),
    new TsChecker({ typescript: { configFile: Path.resolve('tsconfig.json') } }),

推荐阅读