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"
}
}
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.