Cannot access 'DefaultTheme' before initialization
See original GitHub issueMRE: brc-dd/vp-default-theme-bug
Describe the bug
I want to use element-plus.
I refer to the issue 603 and brc-dd/vitepress-element-plus-demo
It works in 1.0.0-alpha.4, but building in 1.0.0-alpha.8 gives an error
build error: ReferenceError: Cannot access ‘DefaultTheme’ before initialization
Reproduction
In 1.0.0-alpha.8 version,create a file .vitepress\theme\index.js
import DefaultTheme from 'vitepress/theme'
import { install } from 'element-plus'
import 'element-plus/dist/index.css'
export default {
...DefaultTheme,
enhanceApp({ app }) {
install(app)
}
}
Expected behavior
No error in building
System Info
System:
OS: macOS 12.2.1
CPU: (8) x64 Apple M1
Memory: 29.13 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 14.19.1 - ~/.nvm/versions/node/v14.19.1/bin/node
Yarn: 1.22.18 - /usr/local/bin/yarn
npm: 6.14.16 - ~/.nvm/versions/node/v14.19.1/bin/npm
Browsers:
Chrome: 104.0.5112.101
Safari: 15.3
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
Issue Analytics
- State:
- Created a year ago
- Comments:13 (1 by maintainers)
Top Results From Across the Web
jest ReferenceError: Cannot access '' before initialization
Something about using const before the imports feels weird to me. The thing is: jest.mock is hoisted. To be able to use a...
Read more >Fix jest mock 'Cannot access before initialization' error
Have you ever run into this error while creating a variable before your jest.mock : const mockIsLoggedIn = jest.fn(); jest.mock('.
Read more >uncaught referenceerror: cannot access 'app' before initialization
The error you shared Uncaught ReferenceError: Cannot access 'variable_name' before initialization is thrown when a lexical variable was accessed before it was ...
Read more >Default theme - Material UI - MUI
Here's what the theme object looks like with the default values.
Read more >Plugin API | VuePress
You could check out Node API for how to use the VuePress app instance in plugin hooks. # Overview. Plugins should be used...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This problem seems to be caused by
Team Page
. It works fine when I comment outTeam Page
.this also works for me seems this issue couse by
VPTeamPage