como ler um arquivo json com javascript

JavaScript
const { read } = require('fs')
const readJsonFile = file => {
  if (file.split('.')[file.split('.').length - 1] !== 'json') return {}

  const fileContent = read(file)

  if (!fileContent) return {}

  return JSON.parse(fileContent)
}
readJsonFile('package.json')
Source

Also in JavaScript: