question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Cannot read properties of undefined (reading 'call')

See original GitHub issue

Bug report

What is the current behavior? Can’t have same package.json name on host and remote. Getting error at some point using module federation, guessing when splitChunks kicks in.

If the current behavior is a bug, please provide the steps to reproduce. Set host’s and remote’s name in package.json to same value. Try to load a remote page large enough to trigger splitting chunks (again guessing).

What is the expected behavior? Should not result in error, or, provides a better error message

Other relevant information:

  • Similar experience as @ydmitry in issue 12964 where there is a point that adding a single line of code to a React component’s render method results in the error, and removing the line clears the error. Line was a simple MUI <Typography> which already appears multiple times in the component.

  • Same as @ydmitry setting splitChunks = false on remote resolved the error

  • Ran across another report of the error https://discourse.aurelia.io/t/aurelia-1-and-webpack-module-federation-plugin-different-package-json-names/4398 which suggested the error occurred when the package.json names were different and setting them to the same name resolved the error.

  • On checking my package names, found they were the same. Removed splitChunks = false, verified error was present again, changed package names to be different, and error was gone.

I’m fine for now. Hope this helps someone else struggling with this error.

webpack version:
Node.js version: Operating System: Additional tools:

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:24 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
jponccommented, May 30, 2022

Just to give some context – I’m currently developing a proof of concept related to microfrontends utilising webpack module federation. I’m also using NX (https://nx.dev/) to handle the different microfrontends. NX has this notion of only having a single package.json (root) instead of having a package.json per individual microfrontend/app.

Solution

Now, webpack assumes that you have defined a “unique” name inside your package.json file per microfrontend in order for it to work. Since I’m using NX, the solution I encountered is to modify the uniqueName attribute in webpack config so it doesn’t rely on the name attribute from package.json.

image

Source: https://webpack.js.org/configuration/

After I’ve added uniqueName per webpack config (one for each microfrontend/app) then it worked as expected and this error went away.

8reactions
jponccommented, May 17, 2022

I’m also getting the same issue. It seems that the host/container is getting confused between installedModules and __webpack_modules__

webpack_modules

webpack/container/reference/marketing

installedModules

webpack/container/remote/marketing/MarketingApp


So now when the code reaches __webpack_modules__[moduleId] it returns undefined because moduleId is webpack/container/remote/marketing/MarketingApp coming from installedModules

localhost_8080

My host configuration looks

image

My App.tsx looks:

image

Which returns an error

image
Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError : Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
TypeError: Cannot read properties of undefined (reading 'call ...
I am running a vite.js app with web3 installed. When I run the app in dev mode, all works fine but when I...
Read more >
Error: Cannot read properties of undefined (reading 'call')
Error: Cannot read properties of undefined (reading 'call'). What do we do to fix this? The page I need help with: [log in...
Read more >
Uncaught TypeError : Cannot read properties of undefined
In JavaScript, properties or functions are Objects, but undefined is not an object type. If you call the function or property on such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found