Last active
February 27, 2019 20:50
-
-
Save SMotaal/e73c12bd801d78a3108fa30ecd303676 to your computer and use it in GitHub Desktop.
Node.js: createRequireFromPath
This file contains 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
module.exports = 'cjs'; |
This file contains 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
import {createRequireFromPath} from 'module'; | |
import {fileURLToPath} from 'url'; | |
const require = createRequireFromPath(fileURLToPath(import.meta.url)); | |
const cjs = require('./cjs'); | |
cjs === 'cjs'; // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment