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

fix(plugin): add missing $ prefix to globalName #356

Merged
merged 1 commit into from
Apr 27, 2020

Conversation

ricosmall
Copy link
Contributor

@ricosmall ricosmall commented Apr 27, 2020

Problem:

The globalName equals nuxt if we didn't set it in nuxt.config.js, when you use window[globalName] which means window['nuxt'] to get global $nuxt, will return undefined, you need use window['$nuxt'] to get it.

Solution:

To get global $nuxt, you need use

window[`$${globalName}`]

So we can define the variable globalName with a $ prefix to make it right.

See source code below to get more info:

https://github.com/nuxt/nuxt.js/blob/85383688371f5ba7b079e1d829a1ada91bc11eaf/packages/config/src/config/_common.js#L16-L23

@codecov
Copy link

codecov bot commented Apr 27, 2020

Codecov Report

Merging #356 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               dev      #356   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           30        30           
  Branches        12        12           
=========================================
  Hits            30        30           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b46693b...8c677c2. Read the comment docs.

@pi0 pi0 changed the title fix(plugin): fixed window[globalName] get undefined error fix(plugin): add missing $ prefix to globalName Apr 27, 2020
@pi0 pi0 merged commit 47788bd into nuxt-community:dev Apr 27, 2020
@pi0
Copy link
Member

pi0 commented Apr 27, 2020

Thanks @ricosmall

@sami-baadarani
Copy link

Getting error "globalName is not defined" in nuxt version 1.4.5
@pi0 @ricosmall

@ricosmall
Copy link
Contributor Author

@sami-baadarani what is the @nuxtjs/axios version you used?

@sami-baadarani
Copy link

@ricosmall We are forced to use version 5.9.7.
The issues with globalName started from version 5.10.0

@pi0
Copy link
Member

pi0 commented Apr 30, 2020

@sami-baadarani Should be fixed by 5.10.3

@sami-baadarani
Copy link

Thanks @ricosmall @pi0 :)

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

Successfully merging this pull request may close these issues.

3 participants