YMMV, but this worked for me to get Remix working on Node 12. I'm using Restify, but this is really just Node 12 polyfill stuff so it should work with other servers/adapters:
- add
fs.promises
as a dependency - make a module
promises-polyfill.js
with the following:// this polyfills promise stuff for `fs` and even makes `require('fs/promises')` work require('fs.promises'); // we also need to polyfill `Promise.all` for remix Promise.all = (promises) => { if (!promises.length) return Promise.resolve([]); if (promises.every(promise => !(promise instanceof Promise))) return new Promise((resolve) => setTimeout(() => resolve(promises))); let responses = []; let resolvedCount = 0; let rejected = false; return new Promise((resolve, reject) => { promises.forEach(async (promise, i) => { try { responses[i] = await promise; resolvedCount++; if (resolvedCount === promises.length) { resolve(responses); } } catch (e) { rejected = true; if (!rejected) reject(e); } }); }); };
- set
NODE_OPTIONS='--experimental-modules -r ./PATH/TO/YOUR/promises-polyfill'
when running any remix commands (e.g.build
orwatch
) as well as for your server process