Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProgressPlugin TypeError: Cannot read property 'tap' of undefined

Tags:

webpack

I'm getting an error during compilation. It seems to not be happy with the ProgressPlugin in webpack:

/node_modules/webpack/lib/ProgressPlugin.js:205
    compilation.hooks.addEntry.tap("ProgressPlugin", entryAdd);

TypeError: Cannot read property 'tap' of undefined

I know there have been some recent changes with plugins for webpack 4. It seems addEntry, failedEntry, succeedEntry are not in the documentation for compilation hooks - https://webpack.js.org/api/compilation-hooks/ - am I missing something?

My package.json deps:

"amazon-cognito-identity-js": "^2.0.30",
"array-move": "^1.0.0",
"aws-sdk": "^2.352.0",
"babel-loader": "^8.0.4",
"babel-plugin-styled-components": "^1.8.0",
"fuse.js": "^3.3.0",
"grid-styled": "^5.0.2",
"json-cycle": "^1.3.0",
"lodash": "^4.17.11",
"next": "^7.0.2",
"next-routes": "^1.4.2",
"node-fetch": "^2.2.1",
"path-match": "1.2.4",
"rc-time-picker": "^3.4.0",
"react": "^16.6.1",
"react-autocomplete": "^1.8.1",
"react-copy-to-clipboard": "^5.0.1",
"react-day-picker": "^7.2.4",
"react-dom": "^16.6.1",
"react-modal": "^3.6.1",
"react-places-autocomplete": "^6.1.3",
"react-scripts": "^1.1.5",
"react-spinners": "^0.4.7",
"react-stripe-checkout": "^2.6.3",
"react-stripe-elements": "^2.0.1",
"refunk": "^3.0.1",
"styled-system-html": "^2.0.2",
"webpack": "^4.25.1",
"webpack-dev-server": "^3.1.10"
like image 513
johnpolacek Avatar asked Nov 09 '18 14:11

johnpolacek


People also ask

What is cannot read property of undefined in JavaScript?

The TypeError: Cannot read property of undefined is one of the most common type errors in JavaScript. It occurs when a property is read or a function is called on an undefined variable. TypeError: Cannot read properties of undefined (reading x) Undefined means that a variable has been declared but has not been assigned a value.

Why can’t I call a function on an undefined variable?

In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.

What is the meaning of undefined in JavaScript?

Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.


2 Answers

You have 2 different version of webpack, the one you installed causing it to break.

Don't install webpack your self ( remove it from package.json ), its already installed with next.js

like image 150
Meabed Avatar answered Sep 18 '22 18:09

Meabed


In my case the error was that I put a plugin under resolve.plugins, instead of directly in plugins inside the webpack config. Solution from: https://github.com/webpack/webpack/issues/8548#issuecomment-449829774

like image 23
Jakub Holý Avatar answered Sep 18 '22 18:09

Jakub Holý