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

Viewed 9551

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)
2 Answers

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

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.

image

Related