Skip to content
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

Cannot read property 'globalLayout' of null #1304

Closed
1 task done
ghost opened this issue Feb 16, 2019 · 5 comments
Closed
1 task done

Cannot read property 'globalLayout' of null #1304

ghost opened this issue Feb 16, 2019 · 5 comments

Comments

@ghost
Copy link

ghost commented Feb 16, 2019

  • I confirm that this is a issue rather than a question.

Bug report

Cannot read property 'globalLayout' of null

Version

vuepress 1.0.0-alpha.38

Steps to reproduce

  1. Create new project
  2. Run vuepress dev (or build)

What is expected?

Development server start

What is actually happening?

TypeError: Cannot read property 'globalLayout' of null
    at AppContext.getThemeConfigValue (/Users/tom/Desktop/test/node_modules/@vuepress/core/lib/prepare/AppContext.js:377:65)
    at AppContext.resolveCommonAgreementFilePath (/Users/tom/Desktop/test/node_modules/@vuepress/core/lib/prepare/AppContext.js:301:35)
    at AppContext.resolveGlobalLayout (/Users/tom/Desktop/test/node_modules/@vuepress/core/lib/prepare/AppContext.js:271:30)
    at AppContext.process (/Users/tom/Desktop/test/node_modules/@vuepress/core/lib/prepare/AppContext.js:99:10)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

Other relevant information

  • Your OS: Mac OSX
  • Node.js version: v11.7.0
  • Browser version: any
  • Is this a global or local install? any
  • Which package manager did you use for the install? any
@TribeWeb
Copy link

TribeWeb commented Feb 17, 2019

Exact same issue both with existing and fresh 1.x projects. Tried putting the example GlobalLayout.vue file in /layouts, /components but same error each time.

@manastalukdar
Copy link

Verified that this issue happens all the way back till alpha.32.

@BuptStEve
Copy link
Contributor

BuptStEve commented Feb 17, 2019

Because of this commit: c91f55a

this.parentThemeEntryFile and this.parentThemePath are null.

@ulivz

@BuptStEve
Copy link
Contributor

BuptStEve commented Feb 17, 2019

There are two errors:

return this.themeEntryFile[key] || this.parentThemeEntryFile[key]

const parent = path.resolve(this.parentThemePath, filepath)

A quick fix for me:

 // ...

  getThemeConfigValue (key) {
    return this.themeEntryFile[key] || 
      (this.parentThemeEntryFile && this.parentThemeEntryFile[key]) // <-- replace by this
  }

  getThemeAgreementFile (filepath) {
    const current = path.resolve(this.themePath, filepath)
    if (fs.existsSync(current)) {
      return current
    }
    if (!this.parentThemePath) return // <-- add this
    const parent = path.resolve(this.parentThemePath, filepath)
    if (fs.existsSync(parent)) {
      return parent
    }
  }

 // ...

@ulivz ulivz closed this as completed in 94dab12 Feb 17, 2019
@ulivz
Copy link
Member

ulivz commented Feb 17, 2019

Thanks for the report, it would be better to create a repro repo (e.g. vuepress-global-layout-repro) at your next time to report issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants