Cannot access '' before initialization #9686
Replies: 13 comments 4 replies
-
I'm facing the same issue. It occurs when using vue router. This is my import router from './plugins/router';
...
const app = createApp(AppRoot);
app.use(router); // <--- Here is the problem :( With that configuration, it throws:
In my import { createRouter, createWebHistory } from 'vue-router';
import routes from '../routes/routes';
export default createRouter({
history: createWebHistory(),
routes,
}); |
Beta Was this translation helpful? Give feedback.
-
Do you have Circular Dependency on |
Beta Was this translation helpful? Give feedback.
-
I'm having the same issue,I referenced the router in the ts file |
Beta Was this translation helpful? Give feedback.
-
I'm having this issue too and if router is relevant then I'm using the TanStack Router. I took care of circular dependencies but that didn't solve the issue. |
Beta Was this translation helpful? Give feedback.
-
Same here! Quite confusing... |
Beta Was this translation helpful? Give feedback.
-
Same problem |
Beta Was this translation helpful? Give feedback.
-
Encountering same problem here |
Beta Was this translation helpful? Give feedback.
-
Same problem |
Beta Was this translation helpful? Give feedback.
-
same problem without any react |
Beta Was this translation helpful? Give feedback.
-
I encountered the same issue while using TanStack Router in my project. Based on my experiments, the problem occurred when importing a resource from my generated file barrel. As a workaround, I was able to resolve it by importing the resource directly from its source file instead. I hope this helps others facing the same issue. |
Beta Was this translation helpful? Give feedback.
-
vite@6.3.0 with @vanilla-extract/vite-plugin@5.0.1 this issue occurred again |
Beta Was this translation helpful? Give feedback.
-
I started having these issues tonight. Only happened when building for prod. After a lot of trial and error I realized the issue. I was sometimes statically importing components
and sometimes dynamically
After changing all to the 2nd format, the error went away. This is using Vite 6.3.1. |
Beta Was this translation helpful? Give feedback.
-
i fix this problem by changing importMode from 'sync' to 'async' in my VueRouter configuration |
Beta Was this translation helpful? Give feedback.
-
I've spent several hours now reviewing existing issues around the error
Cannot access 'ActionTable before initialization
, but none of the existing issues appear to have the same error that I receive.In several of my components, when I save a change, I receive an error similar to above. It's always referencing a component import.
It appears that the
ActionTable
component is being loaded *after theComputerDetailsPage
component, which may be causing theCannot access 'ActionTable before initialization
since ActionTable is loaded after and not before?I've tried detecting circular dependencies, but I cannot find any.
Anyone else experiencing a similar issue?
Posting under discussions because I cannot create a reproduction repo yet
Update:
I am using vue-router v3.5.4, and I believe my issues are stemming from my (perhaps incorrect) use of vue-router.
I have a
router.js
file where I export a router instanceI have helper functions that utilize the router
All components that import
helperFunction
are showing the error I initially posted. However, when I remove the dependency onrouter.js
fromhelpers.js
, the error goes away.I'm almost certain I am incorrectly using the router here, but I haven't noticed any issues with this approach until using vite. Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions