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.

Cannot access 'DefaultTheme' before initialization

See original GitHub issue

MRE: 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:closed
  • Created a year ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
wuchaoxincommented, Aug 20, 2022

I am not able to reproduce this:

image

This problem seems to be caused by Team Page. It works fine when I comment out Team Page.

0reactions
Sepushcommented, Aug 20, 2022

I am not able to reproduce this: image

This problem seems to be caused by Team Page. It works fine when I comment out Team Page.

this also works for me seems this issue couse by VPTeamPage

Read more comments on GitHub >

github_iconTop 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 >

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