Framer motion error: Module not found: Can't resolve 'react'
I just started a new next.js project and I am trying to use framer motion inside it and on importing motion from framer-motion I get the errror below
../node_modules/framer-motion/dist/es/animation/hooks/use-animated-state.mjs:1:0
Module not found: Can't resolve 'react'
https://nextjs.org/docs/messages/module-not-found
here is my import statement
import { motion } from 'framer-motion'
Admin
2023-06-05
This error occurs because React is not installed in your project. To confirm check if react and react-dom are part of your package.json.
If they are not there then add it like this and run npm install again
{
"dependencies": {
"framer-motion": "^10.12.16",
"react": "18.2.0",
"react-dom": "18.2.0"
}
}
Similar Content
- Adding bootstrap to next.js
- Next.js rendering methods
- DeprecationWarning: Using 'compiler' as the first argument is deprecated. Please use 'options' as the first argument and 'compiler' as the second argument error on React Native.
- Setting up dynamic sitemap for next js using Javascript
- Resetting form fields onsubmit in next js
Privacy Policy
By using our website,
you agree that devmaesters can store cookies on your device and disclose information in accordance with our privacy policy.