Skip to content

Instantly share code, notes, and snippets.

@MylesBorins
Created January 4, 2021 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MylesBorins/f0d036ea85c444c4233c8bfda6ded550 to your computer and use it in GitHub Desktop.
Save MylesBorins/f0d036ea85c444c4233c8bfda6ded550 to your computer and use it in GitHub Desktop.
fs/promises polyfill
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