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

$axios is not available #56

Closed
NeOMakinG opened this issue Feb 5, 2018 · 23 comments
Closed

$axios is not available #56

NeOMakinG opened this issue Feb 5, 2018 · 23 comments
Labels
Milestone

Comments

@NeOMakinG
Copy link

NeOMakinG commented Feb 5, 2018

Hello guys,

Someone faced this error on nuxt ? I've added the 2 modules to nuxt.config.js and the auth module return me this error with !this.app.$axios...

Thanks for your response..

NeOMakinG

This question is available on Nuxt.js community (#c43)
@fanckush
Copy link

fanckush commented Feb 5, 2018

Im not sure why this is happening but did you add axios to the modules before auth? like so:

modules: [
'@nuxtjs/axios',
'@nuxtjs/auth'
],

@NeOMakinG
Copy link
Author

Yes exactly did like that !

@fanckush
Copy link

fanckush commented Feb 5, 2018

Thats about all i can help. How about trying a fresh empty nuxt project and install auth immediately after and see if you get a problem, this should narrow down the cause. if it does work maybe then maybe in your current project something is wrong in the nuxt config or code you wrote

Is the error from code you've written or is it internal?

@NeOMakinG
Copy link
Author

NeOMakinG commented Feb 5, 2018

It's an error from the auth-module, in auth.class, because Axios is probably not loaded in the app, but why...

Trying to install a fresh nuxt install to check, thanks for your help anyway ;)

@NeOMakinG
Copy link
Author

Well, tried this on a fresh new app, and It's doing the same thing!

@fanckush
Copy link

fanckush commented Feb 5, 2018

What do you have in package.json in dependencies:{}:

@NeOMakinG
Copy link
Author

"dependencies": { "@nuxtjs/auth": "^4.0.0-rc.3", "@nuxtjs/axios": "^5.0.0", "nuxt": "^1.0.0" }

That's the fresh new app

@fanckush
Copy link

fanckush commented Feb 5, 2018

ok everything seems fine! Are you using a nuxt template or you are doing it from scratch

In my case i am using the starter template from https://github.com/nuxt-community/starter-template and it works

@NeOMakinG
Copy link
Author

Using the starter template on my main app, not working too ^^

@fanckush
Copy link

fanckush commented Feb 5, 2018

lol ok i don't know anymore, update everything :D npm, vue-cli, node

mayble clone this https://github.com/nuxt-community/auth-module/tree/master/example/with-vanilla-nuxt and use it as your base template.

@zalmane
Copy link

zalmane commented Feb 5, 2018

For some bizarre reason it seems you have to add axios last (opposite of what it says in doc):

  modules: [
    '@nuxtjs/auth',
    '@nuxtjs/axios'
  ],

@NeOMakinG
Copy link
Author

Nice !! But strange 👍

Thanks you, should have test it before posting there lol

@pi0
Copy link
Member

pi0 commented Feb 5, 2018

Hey. Thanks for reporting. This is super strange. With the latest release, it should automatically insert itself just after axios. source (And also tests are doing the same order. Actually order shouldn't matter)

Would you please share contents of .nuxt/index.js when axios is the first item?

@NeOMakinG
Copy link
Author

NeOMakinG commented Feb 6, 2018

Hey, No problem !

Here is the index.js file with axios as first :

https://pastebin.com/WyCnJMq5

Looks like axios plugin is imported after Auth one, when Axios is after, in index.js he's imported before auth plugin!

@pi0
Copy link
Member

pi0 commented Feb 6, 2018

import nuxt_plugin_authplugin_72500e98 from 'nuxt_plugin_authplugin_72500e98' // Source: ./auth\auth.plugin.js

Ah, i got it! Windows backslash problem again! Will resolve it soon.

@NeOMakinG
Copy link
Author

Well yeah, sorry for using windob :D

@breakingrobot breakingrobot added this to the 4.0 milestone Feb 13, 2018
@busheezy
Copy link

Thanks for finding the problem. I'm running into this, with the latest published release.

@CoolGoose
Copy link

The fix with the order of the imports from @zalmane still works.
I'm on windows 10, with a fresh npm install on

"dependencies": {
    "@nuxtjs/auth": "^4.0.0-rc.3",
    "@nuxtjs/axios": "^5.0.1",
    "@nuxtjs/vuetify": "^0.4.0",
    "axios": "^0.18.0",
    "nuxt": "^1.0.0",
    "vuetify": "^1.0.0"
},

Node: v8.9.3 npm 5.6

@CoolGoose
Copy link

CoolGoose commented Feb 25, 2018

Actually, it seems that the module resolution errors out incorrectly. Both orders work for the auth/axios
If i don't have the nuxtjs/vuetify entry in the modules it does error out with the error that axios isn't defined.

Nope, I am stupid, order matters, below image is from when it fails.

screen shot 2018-02-25 at 19 26 20-fullpage

syffs pushed a commit to syffs/auth-module that referenced this issue Feb 26, 2018
@breakingrobot
Copy link
Contributor

breakingrobot commented Mar 12, 2018

Closing as solved by be1bed2.

@g0shed
Copy link

g0shed commented Mar 27, 2018

I'm still getting the same error on windows

{ Error: $axios is not available at Auth.get $axios [as $axios] (.nuxt/auth/auth.class.js:93:0) at Auth.setToken (.nuxt/auth/auth.class.js:262:0) at Auth.syncToken (.nuxt/auth/auth.class.js:290:0) at Auth.init (.nuxt/auth/auth.class.js:39:0) at module.exports.__webpack_exports__.a (.nuxt/auth/auth.plugin.js:55:0) at createApp (.nuxt/index.js:166:0) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) statusCode: 500, name: 'NuxtServerError' }

@busheezy
Copy link

@g0shed What version are you using? I don't think we've had an NPM push in a while. A few bugs are fixed and just waiting for an NPM push.

@knight0202
Copy link

``

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

No branches or pull requests

9 participants