How can I read a JSON file into server memory using Node.js?

If the JSON file doesn’t change frequently and is small, you can simply use:

const jsonData = require('./data.json');
console.log(jsonData);

This method is super quick and easy, but Node.js caches the file, meaning if the JSON file is modified, you’ll need to restart your server for changes to reflect.