2

I'm trying to configure the webpack-subresource-integrity package on my config-overrides.js(react-app-rewired):

const { SubresourceIntegrityPlugin } = require('webpack-subresource-integrity');

module.exports = function override(config, env) {
  config.optimization.splitChunks.cacheGroups = {
    ...config.optimization.splitChunks.cacheGroups,
    project: {
      test: /[\\/]node_modules[\\/]@project[\\/]/
    }
  };

  // added this part
  config.output = {
    crossOriginLoading: 'anonymous'
  };

  config.plugins = [...config.plugins, new SubresourceIntegrityPlugin()];


  return config;
};

I get TypeError: Cannot read property 'tap' of undefined

I already tried to delete my node_modules, yarn.lock and then re-install the packages but I still get the same error.

This is the full error:

/Users/me/myProject/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

TypeError: Cannot read property 'tap' of undefined
    at /Users/me/myProject/node_modules/webpack-subresource-integrity/index.js:235:48
    at SyncHook.eval [as call] (eval at create (/Users/me/myProject/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:89:1)
    at SyncHook.lazyCompileHook (/Users/me/myProject/node_modules/tapable/lib/Hook.js:154:20)
    at Compiler.newCompilation (/Users/me/myProject/node_modules/webpack/lib/Compiler.js:631:26)
    at /Users/me/myProject/node_modules/webpack/lib/Compiler.js:667:29
    at _next0 (eval at create (/Users/me/myProject/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at eval (eval at create (/Users/me/myProject/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:26:1)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Kevin Bryan
  • 1,846
  • 2
  • 22
  • 45

1 Answers1

2

I have solution for that will be working fine please follow the below step :

  1. remove the node_modules folder from project directory
  2. remove the package-lock.json file
  3. make sure clear the cache use this command npm cache clean --force
  4. afterward verify the bytes of memory using this command npm cache verify
  5. and then do again use npm install