Home > Net >  issue with React Scripts and terser-webpack-plugin
issue with React Scripts and terser-webpack-plugin

Time:06-03

As of yesterday, I suddenly started getting this error when running the 'npm start' script in my create-react-app. I never had this issue before, and have not changed any configuration or package.json files in or out of react-scripts. terser-webpack-plugin is installed at the location and its "main" is:

"main": "dist/index.js",

I have tried reinstalling node_modules with no luck. I also tried the solution here: Use latest terser-webpack-plugin with Webpack5

      throw err;
      ^

Error: Cannot find module 'Z:\Documents\chat-test\my-app\node_modules\terser-webpack-plugin\dist\index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:353:19)
    at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (Z:\Documents\chat-test\my-app\node_modules\react-scripts\config\webpack.config.js:18:22)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32) {
  code: 'MODULE_NOT_FOUND',
  path: 'Z:\\Documents\\chat-test\\my-app\\node_modules\\terser-webpack-plugin\\package.json',
  requestPath: 'terser-webpack-plugin'
}

CodePudding user response:

Possible fixes, try either or both:

  • npm i --save-dev webpack-terser-plugin
  • Remove package.lock and run npm i

And could you post your package.json?

  • Related