ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema

旧街凉风 提交于 2021-01-28 10:07:40

问题


I just updated some of my packages in my package.json due to vulnerabilities. All vulnerabilities were fixed but the following error appeared when I did npm run. Copy Plugin package got updated during my vulnerability fix.

I tried copying package.json from older commits and reinstalling all packages, but then the vulnerability appears again.

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)

回答1:


For the configuration issues:

Adapt the following section in webpack.common.js only:

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') } }),



回答2:


I had the same problem but with angular 11 and with the dependency "@angular-devkit/build-angular": "~0.1100.5" when executing "tns debug android -no--hmr".

When I updated nativescript to version 7 the file "webpack.config.json" changed the CopyWebpack, and I solved the error by entering the previous configuration as you can see in the image.



来源:https://stackoverflow.com/questions/63379652/validationerror-invalid-options-object-copy-plugin-has-been-initialized-using

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!