Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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