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

391
Views
El código JavaScript que incluye Node.js no se ejecuta completamente

El siguiente es el código guardado en un archivo index.js cuando ejecuto mi código javascript (que incluye el nodo js) no lo ejecuta por completo.

 var fs = require('fs'); var http = require('http'); var url = require('url'); var glob = require( 'glob' ); var language_dict = {}; glob.sync( './language/*.json' ).forEach( function( file ) { let dash = file.split("/"); if(dash.length == 3) { let dot = dash[2].split("."); if(dot.length == 2) { let lang = dot[0]; fs.readFile(file, function(err, data) { language_dict[lang] = JSON.parse(data.toString()); }); } } }); http.createServer(function (req, res) { var q = url.parse(req.url, true); var lang = 'en'; let dash = q.pathname.split("/"); if(dash.length >= 2) { let code = dash[1]; if(code !== '' && language_dict.hasOwnProperty(code)) { lang = code; } } fs.readFile('index.html', function(err, data) { res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'}); let data_string = data.toString(); for (var key of Object.keys(language_dict[lang])) { let pattern = new RegExp("{{" + key + "}}", "g"); data_string = data_string.replace(pattern, language_dict[lang][key]); } res.write(data_string); return res.end(); }); }).listen(8080);

Lo siguiente es lo que sucede en la salida cuando uso: nodo "ruta": ingrese la descripción de la imagen aquí

Esto es lo que sucede cuando utilicé: node index.js: ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
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!