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

643
Views
ReferenceError: require no está definido en el alcance del módulo ES, puede usar import en su lugar

Aquí he mencionado los archivos que he usado. Lo he intentado de ambas maneras, agregando y eliminando la etiqueta "tipo": "módulo" en el archivo package.json.

Aplicación.js

 var http = require('http'); var fs = require('fs'); http.createServer(function (req, res) { fs.readFile('app.html', function(err, data) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write(data); return res.end(); }); }).listen(8080); import { hello } from './sell.js'; hello();

aplicación.html

 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>React JS </title> </head> <body> <h1>JavaScript Tutorial</h1> <script type="module" src="app.js"></script> </body> </html>

vender.js

 export let hello = () => { console.log("heyy shreya suman"); }
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Mira, hay 2 formas de importar algo

  1. var http = require('http');
  2. import http from "http"

Pero no puede usar import y require() al mismo tiempo, no funciona. Usted usa require() o import Y, su tipo de módulo package.json o extensión de archivo debe coincidir con el tipo de importación que está usando

about 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!