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

297
Views
¿Cómo puedo elegir NODE_ENV en la terminal de Windows sin usar npm?

Estoy estudiando un curso de NodeJs, el objetivo principal de este curso es aprender NodeJS sin usar npm, por lo que llegamos a una etapa en la que definimos nuestra variable de entorno para la puesta en escena y la producción, y no pude cambiar entre NODE_ENV desde la terminal cmd , tenemos un archivo config.js que exporta el entorno, el index.js los importa y en base al NODE_ENV solicitado, te lo entrega. -así que este es el script config.js:

 /* **** Creating and exporting config variables */ // var environments = {}; // environments.staging ={ 'port' : 3000, 'envName' : 'staging', } environments.production ={ 'port' : 5000, 'envName' : 'production', } // var currentEnvironment = typeof(process.env.NODE_ENV) == 'string' ? process.env.NODE_ENV.toLowerCase() :''; // var environmentToExport = typeof(environments[currentEnvironment]) == 'object' ? environments[currentEnvironment] : environments.staging; // module.exports = environmentToExport;

y el script Index.js es este:

 var http = require('http'); var url = require('url'); var stringDecoder = require('string_decoder').StringDecoder; var config = require('./config'); var server = http.createServer((req,res)=>{ to many lines i coudln't paste them }); server.listen(config.port,()=>{ console.log("Server listening on port Nº : "+config.port+" in "+config.envName+" environment "); });

Entonces, ¿cómo puedo elegir NODE_ENV desde la terminal?

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

0

Como NODE_ENV es una variable de entorno, puede cambiar esta opción en la sesión de terminal con el set de comandos (en CMD):

 set NODE_ENV=production node index.js
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!