Created
January 4, 2021 15:51
-
-
Save MylesBorins/f0d036ea85c444c4233c8bfda6ded550 to your computer and use it in GitHub Desktop.
fs/promises polyfill
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
try { | |
require('fs/promises'); | |
} catch (e) { | |
const {join} = require('path'); | |
const {promises} = require('fs'); | |
const polyfillRoot = join(__dirname, 'node_modules', 'fs') | |
const polyfillPath = join(polyfillRoot, 'promises.js'); | |
require.cache[polyfillPath] = { | |
id: polyfillPath, | |
path: polyfillRoot, | |
exports: promises, | |
parent: undefined, | |
filename: polyfillPath, | |
loaded: true, | |
children: [], | |
paths: [] | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment