Something weird with the require command. Maybe someone knows what’s going on here?
I literally check that the file exists the line before, and still Node complains the file does not exist! (Or that’s what it seems!)
if (fs.existsSync('../newParamMsgs.json')) {
newParamMsgs = require('../newParamMsgs.json');
fs.copyFile(fname, fname + '.bak', (err) => {
if (err) {
console.log(`Cant open file ${fname}!`);
}
});
} else {
console.log(`${fname} does not exist.`);
}
Error message:
Error: Cannot find module '../newParamMsgs.json'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.setFName (/Users/andyb/Dropbox/Documents/companion/companion/lib/module/yamaha-MIDI/yamaha.js:22:18)
at fs.access (/Users/andyb/Dropbox/Documents/companion/companion/lib/module/yamaha-MIDI/index.js:110:12)
at FSReqWrap.oncomplete (fs.js:135:15)