Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

460
Visualizações
Error importing Framer Motion v5 in React (with create-react-app)

When am trying to do simple animation for div using framer motion. Am getting this following error in browser

/node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs

Can't import the named export 'Children' from non EcmaScript module (only default export is available)```
over 4 years ago · Santiago Trujillo
8 Respostas
Responde à pergunta

0

Solved using this import:

import {motion} from 'framer-motion/dist/es/index'
over 4 years ago · Santiago Trujillo Relatório

0

Here's the response to the issue from the Framer Discord

regarding the issue with the current version of create-react-app (CRA) the issue is being tracked on GitHub here: https://github.com/formatjs/formatjs/issues/1395

After testing a bit it seems that the issue is with how CRA handles ESM dependancies and more particularly transitive dependancies are not handled correctly it seems. There is also an outstanding issue with CRA about this https://github.com/facebook/create-react-app/issues/10356.

Options:

  1. This is fixed/doesn't break in the next version of CRA which you can try today (https://github.com/facebook/create-react-app/discussions/11278) take note though its still in alpha.

  2. You can patch CRA to get around the issue as described in a number of tickets from other libraries

  • https://github.com/formatjs/formatjs/issues/1395#issuecomment-518823361
  • https://github.com/reactioncommerce/reaction-component-library/issues/399#issuecomment-467860022
over 4 years ago · Santiago Trujillo Relatório

0

To Solve Can't import the named export 'Children' from non EcmaScript module (only default export is available) Error You Just need to Downgrade Framer motion version to “4.1. 17” And Now, Your error must be solved.

https://exerror.com/cant-import-the-named-export-children-from-non-ecmascript-module-only-default-export-is-available/

npm i framer-motion@4.1.17
over 4 years ago · Santiago Trujillo Relatório

0

This works for me.

npm uninstall framer-motion
npm install framer-motion@4.1.17
over 4 years ago · Santiago Trujillo Relatório

0

This worked for me:

import {AnimatePresence, motion} from 'framer-motion/dist/framer-motion'
over 4 years ago · Santiago Trujillo Relatório

0

In my opinion downgrading to older version is a last resort because you can't use newer features framer motion gives you.

What should work in this case is just changing import slightly:

import { motion } from 'framer-motion/dist/framer-motion'
over 4 years ago · Santiago Trujillo Relatório

0

I downgraded the Framer motion version to "4.1.17" by changing the package.json file and running npm install and it works for me.

over 4 years ago · Santiago Trujillo Relatório

0

Additional Information:

For people who are struggling with the Could not find a declaration file for module 'framer-motion/dist/framer-motion'. error after applying the solutions above, depending on where you are importing the functions from, here is the trick to make the type works:

  • Create a declaration file in src, e.g. framer-motion.d.ts.
  • Add the following code inside the declaration file that you just created.
declare module "framer-motion/dist/framer-motion" {
  export * from "framer-motion";
}
  • Change the path "framer-motion/dist/framer-motion" to the path you are importing in your APP.
  • Save the .d.ts file and the type should not be bothering you anymore.
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda