-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2.7.x] TypeError: Cannot read properties of undefined (reading 'on') #12627
Comments
After changing function setCurrentInstance(vm) {
if (vm === void 0) { vm = null; }
if (!vm)
currentInstance && currentInstance._scope && currentInstance._scope.off();
currentInstance = vm;
vm && vm._scope && vm._scope.on();
} The issue dissappears and the page renders but I'm getting So I added this to my "resolutions": {
"vue-loader": "15.10.0",
"vue": "2.7.3"
}, |
So yep, issue was due to multiple vue instances bundled, would be nice if this could be detected and have an error message straight away, as this is a common recurring issue, and with this version the error message is different |
same question |
There's not really a way for Vue itself to reliably detect that multiple versions of it is being used - since this can depend on your dependency tree, package manager used, build tool used, and dep install order over time. Even if we special this case, there could be other errors when you have multiple copies of Vue being bundled. One way to avoid this is to always remove your lockfiles and do a fresh install when upgrading major deps like Vue. |
I had the same problem. The hint with the multiple versions helped. Due to upgrade from 2.6.14 to 2.7.8 and some rebasing my
So I removed these lines and after a
|
Thanks. I had the same problem. The hint with the multiple versions helped. |
Just found an edge case where the same error is thrown. The culprit was a custom new Vue({
el: element,
provide: {
- _scope: someScope
+ _customScope: someScope
}
}) I guess the same issue can occur in vue 3. An assertion to prevent internal property overrides could provide a safeguard against such issues. |
Thank you for your hint, same question |
The problem disappeared after I repaired the various npm package versions used in the project and upgraded to vue 2.7.14. |
I've just upgraded to Vue 2.7 and I'm now getting this and can't figure out why. I'm using npm and I don't have multiple versions of vue installed but I have narrowed down this error to only when I'm using router-links (for our legacy app, we have some links that need to be a tags). Any ideas here? |
@leereichardt Look into the router-links library and see if you are also adding Vue within it, which has a different version (not 2.7) |
Sorry, I meant a "router-link" tag, which is all part of vue-router. Vue-router as vue 2.7. I'll check some other libraries I have installed though |
Bumped into similar case: was getting Was caused by "catch-all keys" Proxy instance being passed as component property. Proxy was returning unexpected value for Solution was to update proxy implementation to ignore |
Version
2.7.3
Screen
Steps to reproduce
Unsure, I'm very confident I will not be able to provide a reproduction, this is happening on a big app with a few vuex plugins when upgrading from v2.6.14 to v2.7.3
What is expected?
No error
What is actually happening?
[Vue warn]: Error in nextTick: "TypeError: Cannot read properties of undefined (reading 'on')"
This is on this line https://github.com/vuejs/vue/blob/main/src/v3/currentInstance.ts#L22
It seems in some very obscure case that I will not be able to reproduce (seems triggered by a watcher from vuex)
Based on debugging it seems in some case,
setCurrentInstance
is called on a vm that is still uninitialized and so the_scope
property is stillundefined
when called (as you can see it's a comment, because it's comming from a component with av-if="false"
)The stack strace, shows that it's coming from this
setCurrentInstance
The text was updated successfully, but these errors were encountered: