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

171
Views
Exportación de variables en Node js

Cuando intento exportar variables como esta

 const test1 = [ {numbder:'one', name:'user',tag: 'test'} ] const test2 = [ {numbder:'one', name:'user',tag: 'test'} ] module.exports = { test1, test2 }

y lo importo así

 const test = require('./test.js') myfunction function () { console.log(test1 +'and'+ test2) }

me sale este error:

 ReferenceError: Cannot access 'test1' before initialization

¿alguien podría explicarme cuál es el problema?

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

0

Debe destruir los valores de test .

 const { test1, test2 } = require('./test.js') function myfunction() { console.log(test1 +'and'+ test2) }

otra solución:

 const test = require('./test.js') function myfunction() { console.log(test.test1 +'and'+ test.test2) }
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!