Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

214
Vistas
How to make local .json file accessible from remote machine or folder?

In my program I have .json file that is stored in my local folder. I also have Javascript code in the same folder that accessing this .json file and reads it's values. To access the file I am using:

const data = require('../JS/countries.json');.

The program works perfectly on my local machine, and I have published it on github repository(https://github.com/TheRadioDept/technical-question). However, after I tried cloning this repository into another folder, I faced an error:

code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/me/progs/clonedRepo/technical-question/main.js' ]

[ '/home/me/progs/clonedRepo/technical-question/main.js' ] is the path to cloned repository, it is not original storage of .json file and javascript code. That means that code can only be executed on my local machine from the original folder where I store my JS and JSON files. Is there a way I can run this code and access it in another folder or computer?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

main.js is at the root of your repository. The import

const data = require('../JS/countries.json');

depends on the name of the folder containing your repository. Usually the name of the folder and the name of your repository are similar. That means that most users clone your repository into a folder technical-question and the import fails.

You can remove this dependency with

const data = require('./countries.json');

Now, the name of the parent folder isn't used in the import.

about 4 years ago · Juan Pablo Isaza Denunciar

0

try npm install in your terminal (npm is a package manager). This will install all the modules needed for your project with the help of package.json file which is probably already present in your project. In package.json you can find all the dependancies for your project and npm is going to install all of them in a new folder named node_modules. Hope this makes sense.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda