Created
June 28, 2021 11:12
-
-
Save nberlette/4ef87936c3b553861488bd91bcd9676c to your computer and use it in GitHub Desktop.
2 lines of code to require() JSON in ES modules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
import { createRequire } from "module" | |
const require = createRequire(import.meta.url) | |
const data = require("./data.json") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment