You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装framer-motion后出现useId与useInsertionEffect未找到错误求助

Framer-Motion 安装后编译错误求助

我通过yarn add framer-motion命令安装了framer-motion库,安装过程十分顺畅,未出现任何问题。

当前项目配置如下:
项目配置截图

编译时出现如下错误信息:

ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs 40:13-18
export 'useId' (imported as 'useId') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, version)
 @ ./node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs 5:0-42 57:35-43
 @ ./node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs 5:0-52 102:103-116 160:45-58 177:66-79
 @ ./node_modules/framer-motion/dist/es/index.mjs 3:0-73 3:0-73
 @ ./src/Components/Intro/Intro.jsx 20:0-39 155:37-47
 @ ./src/App.js 8:0-45 35:35-40
 @ ./src/index.js 6:0-24 10:33-36

ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs 58:2-20
export 'useInsertionEffect' (imported as 'useInsertionEffect') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, version)
 @ ./node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs 5:0-42 57:35-43
 @ ./node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs 5:0-52 102:103-116 160:45-58 177:66-79
 @ ./node_modules/framer-motion/dist/es/index.mjs 3:0-73 3:0-73
 @ ./src/Components/Intro/Intro.jsx 20:0-39 155:37-47
 @ ./src/App.js 8:0-45 35:35-40
 @ ./src/index.js 6:0-24 10:33-36

ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs 18:13-18
export 'useId' (imported as 'useId') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, version)
 @ ./node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs 5:0-52 102:103-116 160:45-58 177:66-79
 @ ./node_modules/framer-motion/dist/es/index.mjs 3:0-73 3:0-73
 @ ./src/Components/Intro/Intro.jsx 20:0-39 155:37-47
 @ ./src/App.js 8:0-45 35:35-40
 @ ./src/index.js 6:0-24 10:33-36

ERROR in ./node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs 37:13-18
export 'useId' (imported as 'useId') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, version)
 @ ./node_modules/framer-motion/dist/es/index.mjs 31:0-90 31:0-90 31:0-90
 @ ./src/Components/Intro/Intro.jsx 20:0-39 155:37-47
 @ ./src/App.js 8:0-45 35:35-40
 @ ./src/index.js 6:0-24 10:33-36

ERROR in ./node_modules/framer-motion/dist/es/motion/utils/use-visual-element.mjs 34:2-20
export 'useInsertionEffect' (imported as 'useInsertionEffect') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, usMeMemo, useReducer, useRef, useState, version)
 @ ./node_modules/framer-motion/dist/es/motion/index.mjs 5:0-66 57:30-46
 @ ./node_modules/framer-motion/dist/es/index.mjs 35:0-59 35:0-59
 @ ./src/Components/Intro/Intro.jsx 20:0-39 155:37-47
 @ ./src/App.js 8:0-45 35:35-40
 @ ./src/index.js 6:0-24 10:33-36

ERROR in ./node_modules/framer-motion/dist/es/utils/use-motion-value-event.mjs 10:2-20
export 'useInsertionEffect' (imported as 'useInsertionEffect') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, usMeMemo, useReducer, useRef, useState, version)
 @ ./node_modules/framer-motion/dist/es/index.mjs 21:0-73 21:0-73
 @ ./src/Components/Intro/Intro.jsx 20:0-39 155:37-47
 @ ./src/App.js 8:0-45 35:35-40
 @ ./src/index.js 6:0-24 10:33-36

ERROR in ./node_modules/framer-motion/dist/es/value/use-spring.mjs 43:2-20
export 'useInsertionEffect' (imported as 'useInsertionEffect') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, usMeMemo, useReducer, useRef, useState, version)
 @ ./node_modules/framer-motion/dist/es/index.mjs 14:0-51 14:0-51
 @ ./src/Components/Intro/Intro.jsx 20:0-39 155:37-47
 @ ./src/App.js 8:0-45 35:35-40
 @ ./src/index.js 6:0-24 10:33-36

webpack 5.70.0 compiled with 7 errors in 2804 ms

我已尝试Stack Overflow上的相关解决方案,但问题仍未解决,特此求助。


内容的提问来源于stack exchange,提问作者Lakshay Rohilla

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 10:09:50