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

242
Views
No se pudo compilar. Error en ./src/reportWebVitals.js. reportWebVitals.js: 'importar' y 'exportar' solo pueden aparecer en el nivel superior (3:4)

No puedo ver el problema en webvital.js. Instalé react-router-dom dos veces y luego ocurrió este error y rompí mi código. Descubrí que una solución puede ser comenzar el proyecto desde cero, pero eso no funcionó. También instalé webvitals pero sigue apareciendo el mismo error. ¿Alguien puede tener una idea de cuál será la solución? Puedo ver correctamente el proyecto en github pero no en mi pc. No se está implementando bien y no está actualizando la página web. ¡Muchas gracias por la ayuda! :) Esto es reportWebVirials.js

 const reportWebVitals = (onPerfEntry) => { if (onPerfEntry && onPerfEntry instanceof Function) { import(`web-vitals`).then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { getCLS(onPerfEntry); getFID(onPerfEntry); getFCP(onPerfEntry); getLCP(onPerfEntry); getTTFB(onPerfEntry); }); } }; export default reportWebVitals;

Este es el error:

 Failed to compile. Error in ./src/reportWebVitals.js Syntax error: D:/ELEARNING PATH/CURSADA/PROYECT/PROYECT REWARDS STORE/store-lopez-andrea/src/reportWebVitals.js: 'import' and 'export' may only appear at the top level (3:4) 1 | const reportWebVitals = (onPerfEntry) => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { > 3 | import(`web-vitals`).then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { | ^ 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); @ ./src/index.js 19:23-51

Este es el index.js

 import React from "react"; import ReactDOM from "react-dom"; import "./index.css"; import App from "./App"; import reportWebVitals from "./reportWebVitals"; import AppProvider from "./context/AppContext"; import { BrowserRouter } from "react-router-dom"; ReactDOM.render( <React.StrictMode> <AppProvider> <BrowserRouter> <App /> </BrowserRouter> </AppProvider> </React.StrictMode>, document.getElementById("root") );
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Tuve el mismo problema, seguí adelante con una npm install y luego con npm audit fix --force . Después de esto, reinicié mi aplicación React y ¡funcionó!

about 4 years ago · Juan Pablo Isaza Report

0

Tuve el mismo problema y al ejecutar este comando lo solucioné, gracias a una respuesta en este hilo.

 npm install react-router-dom --save
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!