Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Error al usar swiperjs React - `Se espera que el módulo solicitado 'react' sea del tipo CommonJS`

Estoy construyendo una aplicación React. Soy nuevo en React y JS en general.

Intento importar la biblioteca swiperjs a un proyecto React existente:

 import React, { Component } from "react"; import { Swiper, SwiperSlide } from 'swiper/react'; function HomeBanner(props) { return ( <div > <div> <img src="img/slider/home-3/home-banner/1.jpg" alt="" /> <div className=""> <h5>Mega Sale Nov 2019</h5> <h3> Double Combo With <br /> The Body Shop </h3> <p>Sale up to <strong>50% Off </strong></p> <a className="ps-btn" href="#">Shop Now</a> </div> </div> <div> <img src="img/slider/home-3/home-banner/2.jpg" alt="" /> <div className=""> <h5>Mega Sale Nov 2017</h5> <h3> IKEA Minimalist <br /> Otoman </h3> <p>Discount <strong>50% Off </strong></p> <a className="ps-btn" href="#">Shop Now</a> </div> </div> </div> ) }

Sin embargo, me sale el siguiente error:

 error - file:///User/node_modules/swiper/react/use-isomorphic-layout-effect.js:1 import { useEffect, useLayoutEffect } from 'react'; ^^^^^^^^^ SyntaxError: The requested module 'react' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export. For example: import pkg from 'react'; const { useEffect, useLayoutEffect } = pkg; at ModuleJob._instantiate (internal/modules/esm/module_job.js:96:21) at async ModuleJob.run (internal/modules/esm/module_job.js:134:20) at async Loader.import (internal/modules/esm/loader.js:179:24) { page: '/' }

¿Puede alguien explicar por qué sucede esto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Su entorno de desarrollo no admite paquetes ESM. Verifique su versión de Node ejecutando node -v . El nodo 14 y superior admite la importación de ESM. Actualice la versión de Node o use Swiper 6.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!