auth-module: $auth.loginWith() not working

Version

v4.9.1

Reproduction link

https://codesandbox.io/s/nifty-shtern-4lbdo

Steps to reproduce

  • Go to /login
  • In console you will have the following warnings

./.nuxt/auth/schemes/oauth2.js 142:24-30 "export ‘default’ (imported as ‘nanoid’) was not found in ‘nanoid’ ./.nuxt/auth/schemes/oauth2.js 155:30-36 "export ‘default’ (imported as ‘nanoid’) was not found in ‘nanoid’

  • Click on login with google

  • In console you will see the following errors

TypeError: Object(…) is not a function [Vue warn]: Failed to mount component: template or render function not defined.

What is expected ?

to go to the google login page

What is actually happening?

Nothing happens

Additional comments?

I am using typescript for this project I added ‘@types/nuxtjs__auth’ to my package.json

<div align="right">This bug report is available on Nuxt community (#c607)</div>

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 16
  • Comments: 17 (1 by maintainers)

Most upvoted comments

@yuruyuri16 I found an interim fix that works until this is patched!

I fixed this issue by adding nanoid 2.1.11 as a direct dependency in my project by running… npm i nanoid@2.1.11

I’m having the same issue. But installing nanoid@2.1.11 didn’t work for me. I’m using oauth2 here’s my config:

auth: {
    strategies: {
      auth0: {
        domain: 'secret',
        client_id: 'secret',
        audience: ''secret',
      },
    },
  },

error:

oauth2.js?3a82:92 Uncaught (in promise) TypeError: Object(...) is not a function
    at Oauth2Scheme.login (oauth2.js?3a82:92)
    at Auth.login (auth.js?facc:131)
    at eval (auth.js?facc:123)

this issue still exists can confirm

doing npm install nanoid@2.1.11 worked for me as well

@Will-Burgon you should never touch any of the files in the .nuxt directory. They are the result of the webpack compilation.

Doing an npm install nanoid@2.1.11 worked for me.

I have encountered this as well, and I have found what I believe the issue is.

If you go to ./.nuxt/auth/schemes/oauth2.js and update this line… import nanoid from 'nanoid' to this… import { nanoid } from 'nanoid', it works.

But the second Nuxt’s hot reload kicks in, it will revert it back to the broken state.

doing npm install nanoid@2.1.11 worked for me as well.

When can this be fixed? This is a pretty crazy workaround.

Thanks @heyshadowsmith, will try this later, been bugging me for the last few hours that I have to change the import of nanoid in the ./.nuxt/auth/schemes/oauth2.js file everytime the app rebuilds.