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

103
Views
(nodo: 9374) Advertencia: para cargar un módulo ES, establezca "tipo": "módulo"

Acabo de empezar a aprender React hoy. ¿Cómo me deshago de ese mensaje de error en mi Consola en la Terminal en Visual Studio?

 (node: 9374)Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. /Users/nishihaider/workspace-ui/react-todo-app/src/App.js:1
 import React from "react"; import "./App.css"; function App() { <> return ( <h1>ToDo</h1> ); </> } export default App;
over 4 years ago · Santiago Trujillo
6 answers
Answer question

0

agregando la línea "tipo": "módulo" en su archivo package.json y, en su lugar, cambie el nombre de su archivo app.js (o lo que sea) a app.mjs.

over 4 years ago · Santiago Trujillo Report

0

para agregar Tipo: módulo en package.json - ayuda :)

paquete.json contiene:

 { "name": "react_template", "version": "1.0.0", "description": "", "main": "index.js", "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "devDependencies": { "webpack": "^5.30.0", "webpack-cli": "^4.6.0" } }
over 4 years ago · Santiago Trujillo Report

0

también está rodeando la declaración de devolución con React Fragments, lo cual no es correcto. Su declaración de devolución debe tener el siguiente aspecto:

 import React from "react"; import "./App.css"; function App() { return ( <> <h1>ToDo</h1> </> ); } export default App;

Estoy bastante seguro de que esta fue la fuente de sus problemas todo el tiempo y no el problema de importación/exportación del módulo.

over 4 years ago · Santiago Trujillo Report

0

Solo necesita actualizar package.json de esta manera,

 {"type": "module"}

A mi me funciono, gracias!

over 4 years ago · Santiago Trujillo Report

0

Primero, instale la última versión de Node.js. Tiene las últimas y mejores características.

En segundo lugar, agregue la línea "type": "module" en su archivo package.json .

 { "type": "module" }

En tercer lugar, use la --experimental-modules al invocar nodejs:

node --experimental-modules app.js

¡Usted debe ser bueno para ir!

Una alternativa es evitar agregar la línea "type": "module" en su archivo package.json y, en su lugar, cambiar el nombre de su archivo app.js a app.mjs.

Tenga en cuenta que ahora la sintaxis require() dejará de funcionar .

over 4 years ago · Santiago Trujillo Report

0

Aquí está mi enfoque:

1 - Actualice package.json como:

 "main": "index.js", "type":"module",

2 - use.js al importar, como:

 import {isPrime} from './isPrime.js';

3 - aquí está isPrime.js

 export const isPrime ....
over 4 years ago · Santiago Trujillo 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!