Using Node.js require vs. ES6 import/export

Update Since Node v12 (April 2019), support for ES modules is enabled by default, and since Node v15 (October 2020) it’s stable (see here). Files including node modules must either end in .mjs or the nearest package.json file must contain “type”: “module”. The Node documentation has a ton more information, also about interop between CommonJS and ES modules. Performance-wise there is always the … Read more

Babel 7 – ReferenceError: regeneratorRuntime is not defined

Updated Answer: If you are using Babel 7.4.0 or newer, then @babel/polyfill has been deprecated. Instead, you will want to use the following at the top of your main js file (likely index.js or similar): Install these packages either with npm: or with yarn: Original Answer: I just encountered this problem and came across the … Read more