You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uncaught TypeError: Cannot read property 'call' of undefined #959
I'm having an issue with webpack where if I stop watching and restart, it will build just fine, but if I edit a file and save it, the incremental build fails with this error:
Uncaught TypeError: Cannot read property 'call' of undefined
Hunting it down there's a module that does not get included in the incremental change build. Best guess is the path followed to re-make the bundle file is not being followed correctly. Upon re-running (stop and start), the missing module is included.
webpack.config.js (module names changed to protect the innocent):
Is it really a incorrect bundle/chunk file or is the file in the browser cache just old?
Reacted by Imran Ali, Asad Ullah, 杂货铺老板, yve2, Nakul Kundaliya, Amr, Tom Hughes, Jaison James, Mehdi Daalvand, Thomas-Sparber and 72 more
Reacted by Brennan, qqqian0819, Yasin Asadnezhad, Vlad, Sergio A., Elmut, Marcelo Cardoso, Mohammed Seyam, Herz3h, Ali Salmabadi and 8 more
Reacted by Ahmed waleed, Shahid Karimi, Marcelo Cardoso, Lukas Borawski, anshulgupta1996, Miguel Pineda, Marcelo Brito, Débora Ornellas and Mateusz Więckowski
Reacted by kilanny, soheilhbr, Johan Nieto, Sam Boylett, Benoît Petitcollot, Miguel Pineda, Marcelo Brito and Delvin Alfredo Binnendijk
Reacted by Sergio A., Elmut, Shahid Karimi, Marcelo Cardoso, kenanaReda, EnricoMathias, Miguel Pineda, Marcelo Brito, rosie ❤ , Jagjeet Singh and 5 more
Reacted by Shahid Karimi, kenanaReda, Tabrez Basha, Marcelo Cardoso, Marcelo Brito, Débora Ornellas and Mateusz Więckowski
Reacted by kl29, Dominic Nguyen, Marcelo Brito and zwbcc
It is really an incorrect bundle/chunk, I've flushed the browser to make sure of that.
Essentially, the module trying to be required is 100% missing on an incremental watch build.
Doesn't happen all the time.
For instance, using reactjs key mirror, on a list of constants, I'd require('react/lib/keyMirror'). On first build, no problem. On watch build, keyMirror module is completely missing from the file where it used to be.
I'm still having this issue with 1.8.4. Pretty much the same setup as @kfancy, except my loader is jsx-loader?harmony
Worth mentioning is that it started happening after upgrading to react 0.13.1. I was porting code from 0.12 and didn't have issues even with webpack 1.7.2. Upgraded react, started having the issue, upgraded webpack to 1.8.4, and the issue still persist. I even removed the CommonsChunckPlugin to see if that would fix the problem, but no luck with that either.
I'm also getting random errors like Uncaught Error: Cannot find module "classnames" every now and then, only when running --watch.
I'm still seeing this issue. Using the latest version v1.10.1
First build works fine, but incremental builds fail. I get the following error from my bundle: Uncaught TypeError: Cannot read property 'apply' of undefined
It seems to break on the usage of apply in this function.
function(modules){// Check all modules for deduplicated modulesfor(variinmodules){if(Object.prototype.hasOwnProperty.call(modules,i)){switch(typeofmodules[i]){case"function": break;case"object":
// Module can be created from a templatemodules[i]=(function(_m){varargs=_m.slice(1),fn=modules[_m[0]];returnfunction(a,b,c){fn.apply(this,[a,b,c].concat(args));// Breaks here};}(modules[i]));break;default:
// Module is a copy of another modulemodules[i]=modules[modules[i]];break;}}}returnmodules;}
The hashes of the builds are different.
Reacted by Jason Miller, Jesus Cruz, 自助者, xsuns, August Flanagan, Alexander Buzin 🇺🇦, qiqi, David Patrick, Josh Strobel, Tg and 7 more
I seem to be having this issue as well. It has been happening for the past few days, not sure if it was a webpack change or a code change that caused this. Let me know if I can help provide any info to track it down.
Was able to fix it with a combination of chunk hashing and webpack route prefetching. The prefetching logic prevents the client from requesting outdated chunks, and the chunk hashing forces the chunks to update once new ones are available server side. With only one or the other, chunks either crash or fail to update. I believe this is because we have code splitting implemented in our react appRoot.
I would also like to note the often proposed solution of adding chunksSortMode: 'dependency' completely broke our update cycle and prevented the app from properly updating at all. I dont recommend it for production code.
My fix: (Webpack 4.46.0 & react 16.14.0 with HtmlWebpackPlugin)
In webpack config, in output, add chunkFilename: '[id].chunk.[chunkhash].js', as proposed by @nicolaelitvac
Note: This solution only worked perfectly after the second app update as the prefetching logic must be live on the client to prevent loading outdated chunks.
Edit: This did not entirely fix our issue and the problem persists :(
Reacted by Ross Hill, Bobae Kang, Kamil Kiełczewski and johnzenza
I also encountered a similar problem in my project. After troubleshooting for a long time, I found that it might be a problem with scope hoisting enabled. Finally, I temporarily solved this problem by commenting out optimization.concatenateModules: true in the wepack configuration
The chunk is created successfully, based on this webpack output: asset view-support.js 29.4 KiB [emitted] (name: view-support)
When trying to navigate to that route, I keep getting (consistently) the error
`[vue-router] Failed to resolve async component default: TypeError: Cannot read property 'call' of undefined
TypeError: Cannot read property 'call' of undefined
at webpack_require (main.js:26989)
at Function.fn (main.js:27159)`
Activity
sokra commentedon Apr 9, 2015
Is it really a incorrect bundle/chunk file or is the file in the browser cache just old?
sokra commentedon Apr 10, 2015
Maybe it's fixed... Please reopen if still an issue with 1.8.4
kfancy commentedon Apr 10, 2015
It is really an incorrect bundle/chunk, I've flushed the browser to make sure of that.
Essentially, the module trying to be required is 100% missing on an incremental watch build.
Doesn't happen all the time.
For instance, using reactjs key mirror, on a list of constants, I'd require('react/lib/keyMirror'). On first build, no problem. On watch build, keyMirror module is completely missing from the file where it used to be.
makedonian commentedon Apr 13, 2015
I'm still having this issue with 1.8.4. Pretty much the same setup as @kfancy, except my loader is
jsx-loader?harmonyWorth mentioning is that it started happening after upgrading to react 0.13.1. I was porting code from 0.12 and didn't have issues even with webpack 1.7.2. Upgraded react, started having the issue, upgraded webpack to 1.8.4, and the issue still persist. I even removed the CommonsChunckPlugin to see if that would fix the problem, but no luck with that either.
I'm also getting random errors like
Uncaught Error: Cannot find module "classnames"every now and then, only when running --watch.DanielApt commentedon Jul 3, 2015
I'm still seeing this issue. Using the latest version v1.10.1
First build works fine, but incremental builds fail. I get the following error from my bundle:
Uncaught TypeError: Cannot read property 'apply' of undefinedIt seems to break on the usage of
applyin this function.The hashes of the builds are different.
DanielApt commentedon Jul 3, 2015
It has something do with our entry points:
We have issues when we use:
When removing
testBundlethings work nicely. Strangely enough the bundle throwing the error is actuallyapp.jsPS: Sorry for the strange file system. We should address this once we have the chance.
DanielApt commentedon Jul 23, 2015
@sokra could you re-open this issue?
sokra commentedon Jul 23, 2015
Could you try upgrading to the lasted version?
DanielApt commentedon Jul 23, 2015
Done. Still an issue.
jeffutter commentedon Aug 11, 2015
I seem to be having this issue as well. It has been happening for the past few days, not sure if it was a webpack change or a code change that caused this. Let me know if I can help provide any info to track it down.
Cap32 commentedon Aug 13, 2015
😭I'm still seeing this issue. Using the latest version v1.11.0
fxmaxvl commentedon Aug 27, 2015
Is there any progress on this issue?
owais commentedon Aug 30, 2015
I'm facing this issue only when I use ExtractTextPlugin + SplitByPathPlugin (or split by name). It goes away if I remove either one of them.
257 remaining items
Ys-sudo commentedon May 15, 2020
My story with it:
webpack.prod.js - bug:
webpack.prod.js - fix:
//'webpack/hot/only-dev-server',beejaz commentedon Aug 24, 2020
I had the same problem with this error message. I removed a empty style tag in my newly added component that cause the issue:
After that it worked again!
restuwahyu13 commentedon Sep 14, 2020
follow step by step this solution for fix this problem, working with me using webpack 4
1.STEP ONE
output: {
library: '[name]',
umdNamedDefine: false
}
optimization: {
concatenateModules: false,
providedExports: false,
usedExports: false
}
STEP TWO
remove symlink and caheWithContenxt
STEP THREE
remove react hot module or disable this for production
STEP FOUR
remove old project name in heroku, after remove old project create new project name
softmarshmallow commentedon Oct 4, 2020
TypeError: Cannot read property 'Reflect' of undefinedwhen using reflect-metadataEugeneJang commentedon Mar 18, 2021
never ending..
florton commentedon Mar 31, 2021
Was able to fix it with a combination of chunk hashing and webpack route prefetching. The prefetching logic prevents the client from requesting outdated chunks, and the chunk hashing forces the chunks to update once new ones are available server side. With only one or the other, chunks either crash or fail to update. I believe this is because we have code splitting implemented in our react appRoot.
I would also like to note the often proposed solution of adding
chunksSortMode: 'dependency'completely broke our update cycle and prevented the app from properly updating at all. I dont recommend it for production code.My fix: (Webpack 4.46.0 & react 16.14.0 with HtmlWebpackPlugin)
chunkFilename: '[id].chunk.[chunkhash].js',as proposed by @nicolaelitvacimport(/* webpackPrefetch: true */ './path/to/SettingsPage.js');Note: This solution only worked perfectly after the second app update as the prefetching logic must be live on the client to prevent loading outdated chunks.
Edit: This did not entirely fix our issue and the problem persists :(
Superwzw commentedon Jun 25, 2021
I also encountered a similar problem in my project. After troubleshooting for a long time, I found that it might be a problem with scope hoisting enabled. Finally, I temporarily solved this problem by commenting out optimization.concatenateModules: true in the wepack configuration
alexander-akait commentedon Jun 25, 2021
@Superwzw What is webpack version?
namnguyen2091 commentedon Jul 2, 2021
just clear cache in my case
JustAnotherSoftwareDeveloper commentedon Sep 2, 2021
Why is this closed? This is still an issue
WesleyHendon commentedon Sep 9, 2021
I can confirm this is still an issue.
I am using webpack 5.30 and vue 2.6.11
I am trying to implement lazy loading on our already existing vue app to reduce our bundle size. Here is how I am importing the component:
const ManageSupport = () => import(/* webpackChunkName: "view-support" */ 'components/helpdesk/view-support')The chunk is created successfully, based on this webpack output:
asset view-support.js 29.4 KiB [emitted] (name: view-support)When trying to navigate to that route, I keep getting (consistently) the error
`[vue-router] Failed to resolve async component default: TypeError: Cannot read property 'call' of undefined
TypeError: Cannot read property 'call' of undefined
at webpack_require (main.js:26989)
at Function.fn (main.js:27159)`
A snippet from main.js where the error is thrown:
My webpack configuration:
My package.json
alexander-akait commentedon Sep 9, 2021
Update webpack to the latest version, also please update
webpack-dev-serverSuperwzw commentedon Dec 28, 2021
@alexander-akait my webpack version is:
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.2"
alexander-akait commentedon Dec 28, 2021
Can you migrate on webpack v5?
jiangxiaoqiang commentedon Jan 16, 2022
Today I am facing the same issue: https://stackoverflow.com/questions/70728473/uncaught-typeerror-cannot-read-properties-of-undefined-reading-call-when-up