Module not found: Can't resolve 'react-hook-form'. NextJS
See original GitHub issueDescribe the bug
I am using nextjs. All works when running dev but when I do npm run build get an error: Module not found: Can't resolve 'react-hook-form.
To Reproduce
npm run build- Error in console
My code
import { useForm } from 'react-hook-form';
import { Input, Button } from '@/atom/form';
export default function CourseLandingPage({ onSubmit }) {
const { register, handleSubmit, watch, errors } = useForm();
return (
<form onSubmit={handleSubmit(onSubmit)}>
<div className='bg-light px-4 py-2'>
<Button secondary>Create a new course</Button>
</div>
<div className='mt-5'>
<Input
lg
name='name'
label='Course name'
defaultValue={name}
refProp={register({ required: true })}
errors={errors}
error='This field is required'
/>
</div>
</form>
);
}
My build “react-hook-form”: “^6.15.1”, “next”: “^10.0.6”, “next-auth”: “^3.2.0”, “react”: “16.13.1”,
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
useForm and react-hook-form is giving problems with I use it ...
Try to go to package.json , see if you already have react-hook-form library in it. · run yarn or npm install on your...
Read more >Module not found: Can't resolve 'react-hook-form-resolvers' #6
Install the module using npm install react-hook-form-resolvers . Then import yupResolver . ... When I look into the node_modules/react-hook-form- ...
Read more >react-hook-form - npm
Performant, flexible and extensible forms library for React Hooks. Latest version: 7.41.1, last published: a day ago.
Read more >Get Started | React Hook Form - Simple React forms validation
One of the key concepts in React Hook Form is to register your component into the hook. This will make its value available...
Read more >Invalid Hook Call Warning - React
You might be using a version of react-dom (< 16.8.0) or react-native (< 0.59) that doesn't yet support Hooks. You can run npm...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
After leaving only the page with the form all works… I will have to dig more and see why I have it on my end
ok, let me know if anything I can help, i will close it for now.