Skip to content

Instantly share code, notes, and snippets.

@jkeefe
Created March 31, 2022 23:27
Show Gist options
  • Save jkeefe/577c3ece872f451fc62510544547ec22 to your computer and use it in GitHub Desktop.
Save jkeefe/577c3ece872f451fc62510544547ec22 to your computer and use it in GitHub Desktop.
nifty trick to bring in json files using require in a module
// nifty trick to bring in json files using require in a module
import { createRequire } from "module"; // Bring in the ability to create the 'require' method
const require = createRequire(import.meta.url); // construct the require method
const trainData = require('./src/data/latest.json')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment