I am currently working on a project that involves a .json file stored in my local folder. Along with the file, I have Javascript code in the same directory to access and read the values from the .json file. To open the file, this is the line of code I use:
const data = require('../JS/countries.json');
.
Everything runs smoothly on my personal machine, and I have even shared the project on a github repository(https://github.com/TheRadioDept/technical-question). However, when attempting to clone this repository into another folder, I encountered an error:
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/me/progs/clonedRepo/technical-question/main.js' ]
[ '/home/me/progs/clonedRepo/technical-question/main.js' ]
represents the path to the cloned repository, which is not the original location of the .json file and javascript code.
This indicates that the code can only be run on my personal machine from the original folder where the JS and JSON files are stored. Is there a way to execute this code and access it from another folder or device?