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

ESLint error: Unable to resolve path to module '@hookform/resolvers' #19

Closed
minimaluminium opened this issue Jul 7, 2020 · 18 comments
Closed
Labels
bug Something isn't working

Comments

@minimaluminium
Copy link

Shows an ESLint error says Unable to resolve path to module '@hookform/resolvers'. I can use the resolver without any issue, just a lint error.

Screen Shot 2020-07-07 at 2 10 43 PM

@bluebill1049
Copy link
Member

Thanks @minimaluminium can you try to remove node_module and install it again? I don't see the issue at my end. Mabye that will resolve the problem.

@minimaluminium
Copy link
Author

Hi. Removed node_modules and installed again, but same as before. I imported like below and the error is gone.

import {yupResolver} from '@hookform/resolvers/dist'

@bluebill1049
Copy link
Member

hmmm this is strange.

@bluebill1049
Copy link
Member

FYI @kotarella1110

@r-tae
Copy link

r-tae commented Jul 7, 2020

I'm getting a compile error that was also solved by that import:

./node_modules/@hookform/resolvers/dist/index.esm.js Attempted import error: 'appendErrors' is not exported from 'react-hook-form'.

Just thought I'd leave this comment in case it's somehow related...

@bluebill1049
Copy link
Member

thanks @actual-size which version of RHF you are using?

@kotarella1110
Copy link
Member

@minimaluminium please provide .eslintrc.js.

@r-tae
Copy link

r-tae commented Jul 7, 2020

@bluebill1049 RHF ^5.7.2 and @hookform/resolvers 0.0.5

@bluebill1049
Copy link
Member

@actual-size v5 doesn't need resolver, resolver is for v6 :)

@minimaluminium
Copy link
Author

@kotarella1110 Here it is.

{
  "extends": ["wesbos"],
  "rules": {
    "no-nested-ternary": 0,
    "prettier/prettier": [
      "error",
      {
        "semi": false,
        "bracketSpacing": false,
        "singleQuote": true
      }
    ]
  }
}

@fcrezza
Copy link

fcrezza commented Jul 7, 2020

use validationSchema for v5

const schema = // your schema

const {register, handleSubmit} = useForm({
validationSchema: schema
})

@mrlubos
Copy link

mrlubos commented Jul 8, 2020

Same issue and what @minimaluminium said fixed it, using react-hook-form 6.0.1. Could be related to using TypeScript?

@bluebill1049
Copy link
Member

@mrlubos is it eslint as well?

@bluebill1049 bluebill1049 added the bug Something isn't working label Jul 9, 2020
@snmgian
Copy link
Contributor

snmgian commented Jul 9, 2020

#23

@bluebill1049
Copy link
Member

Thanks, heaps @snmgian I will release a patch now.

@bluebill1049
Copy link
Member

before I close this, how did you find out it was due to that? @snmgian

@snmgian
Copy link
Contributor

snmgian commented Jul 9, 2020

My app's build process was running and ok, and the app was also running ok. Only eslint was complaining. When I faced those errors in the past, it was related to a package not being installed properly or not being installed at all.

As package.json tells where's the file that is going to be imported, my first step was to look at the package.json. Then I found the missing dist/ path in jsnext:main.

As eslint-plugin-import uses jsnext:main entry, I tested it locally by fixing that path, run the linter again with no errors this time.

@bluebill1049
Copy link
Member

nice @snmgian thanks for saving all of us! publish the patch now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants