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

Next.js build cannot resolve 'react-use-auth/auth0' #129

Closed
jasonLaster opened this issue Dec 16, 2020 · 8 comments
Closed

Next.js build cannot resolve 'react-use-auth/auth0' #129

jasonLaster opened this issue Dec 16, 2020 · 8 comments

Comments

@jasonLaster
Copy link
Contributor

I went through these steps this morning and ran into a build issue.

  1. npx create-next-app
  2. yarn add react-use-auth auth0-js
  3. update pages/_app.js from https://useauth.dev/docs/auth0/
  4. yarn build
  5. yarn dev

Build Error

here's what i see when i run yarn dev

➜  next-auth git:(main) yarn dev
yarn run v1.22.4
$ next dev
ready - started server on http://localhost:3000
error - ./node_modules/react-use-auth/dist/react-use-auth.esm.js:1:4504
Module not found: Can't resolve 'react-use-auth/auth0'

node_modules files

Here are the files I see in react-use-auth

node_modules/react-use-auth
├── LICENSE
├── README.md
├── dist
│   ├── AuthConfig.d.ts
│   ├── AuthProvider.d.ts
│   ├── NetlifyIdentity.esm.js
│   ├── NetlifyIdentity.esm.js.map
│   ├── NetlifyIdentity.js
│   ├── NetlifyIdentity.js.map
│   ├── NetlifyIdentity.modern.js
│   ├── NetlifyIdentity.modern.js.map
│   ├── NetlifyIdentity.umd.js
│   ├── NetlifyIdentity.umd.js.map
│   ├── __tests__
│   │   ├── AuthConfig.spec.d.ts
│   │   ├── AuthProvider.spec.d.ts
│   │   ├── authReducer.spec.d.ts
│   │   └── useAuth.spec.d.ts
│   ├── auth0.esm.js
│   ├── auth0.esm.js.map
│   ├── auth0.js
│   ├── auth0.js.map
│   ├── auth0.modern.js
│   ├── auth0.modern.js.map
│   ├── auth0.umd.js
│   ├── auth0.umd.js.map
│   ├── authReducer.d.ts
│   ├── index.d.ts
│   ├── index.js
│   ├── index.js.map
│   ├── index.modern.js
│   ├── index.modern.js.map
│   ├── index.module.js
│   ├── index.module.js.map
│   ├── index.umd.js
│   ├── index.umd.js.map
│   ├── providers
│   │   ├── NetlifyIdentity.d.ts
│   │   ├── auth0.d.ts
│   │   └── index.d.ts
│   ├── react-use-auth.esm.js
│   ├── react-use-auth.esm.js.map
│   ├── react-use-auth.js
│   ├── react-use-auth.js.map
│   ├── react-use-auth.modern.js
│   ├── react-use-auth.modern.js.map
│   ├── react-use-auth.umd.js
│   ├── react-use-auth.umd.js.map
│   ├── types.d.ts
│   └── useAuth.d.ts
├── package.json
└── src
    ├── AuthConfig.tsx
    ├── AuthProvider.tsx
    ├── __tests__
    │   ├── AuthConfig.spec.tsx
    │   ├── AuthProvider.spec.tsx
    │   ├── authReducer.spec.ts
    │   └── useAuth.spec.tsx
    ├── authReducer.ts
    ├── index.ts
    ├── providers
    │   ├── NetlifyIdentity.ts
    │   ├── auth0.ts
    │   └── index.ts
    ├── types.ts
    └── useAuth.ts
@catrawalkar
Copy link

Facing Same Problem.

@yjean
Copy link

yjean commented Dec 16, 2020

Same module resolution issue from a create-react-app app.

@jasonLaster
Copy link
Contributor Author

I haven't done this yet, but it would probably be pretty easy to bisect the problem with a local copy of react-use-auth and npm link

@Swizec
Copy link
Owner

Swizec commented Dec 17, 2020

Okay lesson learned, don't test things in the examples/ directory of a library :D

This line in AuthProvider is the problem:

import("react-use-auth/auth0").then(({ Auth0 }) => {

If I change it to ./providers/auth0, it gets confused about importing TS files.

Seems like the only way to fix it is breaking backwards compatibility. Which is better than the library not working, bye bye <AuthProvider>

@yjean
Copy link

yjean commented Dec 17, 2020

As it was introduced in a new major release, breaking backward compatibility makes sense for me.

Unfortunately, that's just my user point of view, I don't know how to help technically on this.

@Swizec
Copy link
Owner

Swizec commented Dec 17, 2020

Just released v2.0.2 that fixes this. Thanks for reporting @jasonLaster

@Swizec Swizec closed this as completed Dec 17, 2020
@Swizec
Copy link
Owner

Swizec commented Dec 17, 2020

@all-contributors add @jasonLaster for bugs

@allcontributors
Copy link
Contributor

@Swizec

I've put up a pull request to add @jasonLaster! 🎉

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