How to run Node.js app with ES6 features enabled?

Add the babel-cli and babel-preset-es2015 (aka ES6) dependencies to your app’s package.json file and define a start script: { “dependencies”: { “babel-cli”: “^6.0.0”, “babel-preset-es2015”: “^6.0.0” }, “scripts”: { “start”: “babel-node –presets es2015 app.js” } } Then you can simply execute the following command to run your app: npm start If you ever decide to stop … Read more

What does “The code generator has deoptimised the styling of [some file] as it exceeds the max of “100KB”” mean?

This is related to compact option of Babel compiler, which commands to “not include superfluous whitespace characters and line terminators. When set to ‘auto’ compact is set to true on input sizes of >100KB.” By default its value is “auto”, so that is probably the reason you are getting the warning message. See Babel documentation. … Read more

Upgrade to Babel 7: Cannot read property ‘bindings’ of null

In your .babelrc file, change { “presets”: [“env”] } to { “presets”: [“@babel/preset-env”] } (and install that package if you haven’t already). In your .babelrc you are still referencing the package babel-preset-env (which is for 6.x), you want to reference @babel/preset-env instead (which is for 7.x). https://github.com/babel/babel/issues/6186#issuecomment-366556833 Note: you should also make this change in … Read more

Is there a way to render multiple React components in the React.render() function?

Since the React v16.0 release you can render an array of components without wrapping items in an extra element when you are inside a component: render() { return [ <li key=”one”>First item</li>, <li key=”two”>Second item</li>, <li key=”three”>Third item</li>, <li key=”four”>Fourth item</li>, ]; } Remember only to set the keys. UPDATE Now from the 16.2 version … 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): import “core-js/stable”; import “regenerator-runtime/runtime”; Install these packages either with npm: npm install –save core-js npm install –save regenerator-runtime or with … Read more