Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module ‘babel-preset-react’

in your webpack config did you already try @babel/preset-react instead of just react? Btw. you test for /\.js$/ Better test for /\.jsx?$/ (x? means x is optional), because you import a .jsx file in your index.js Not options: { presets: [‘react’] } but options: { presets: [‘@babel/preset-react’] }

How to load es6, react, babel code in html with cdn?

You need to use babel standalone script to transpile the code, and you need to include the script for react and react-dom. If you include these tags in your <head>, it will work: <script src=”https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.24.0/babel.js”></script> <script src=”https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js”></script> <script src=”https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js”></script> Reason why it works with codepen: check the setting/javascript, there you will find the babel is … Read more

Import ES module in Next.js ERR_REQUIRE_ESM

From Next.js 12, support for ES Modules is now enabled by default, as long as the ESM library has “type”: “module” in its package.json. Using next-transpile-modules to transpile ESM libraries is no longer required. Before Next.js 12 Since ky is exported as ESM you can transpile it with next-transpile-modules in next.config.js. // next.config.js const withTM … Read more

using async/await with webpack-simple configuration throwing error: RegeneratorRuntime not defined

In order to use await/async you will need to install a couple of Babel dependencies. This works with Vuejs project – npm install –save-dev babel-polyfill npm install –save-dev babel-plugin-transform-regenerator Once installed, you will need to modify your .babelrc file to use the plugin as follows – { “plugins”: [“transform-regenerator”] } and also your webpack.config.js file … Read more

require(‘babel/register’) doesn’t work

Since Babel 6 use babel-register hook to make on-the-fly transpilation. First: npm install babel-register Then require it with: require(‘babel-register’); // not using // require(‘babel/register’); // or // require(‘babel-core/register); To Convert your Ecmascript 6 code to ecmascript 5, you must set Babel presets option with require babel-register Like this: require(‘babel-register’)({ presets: [ ‘es2015’ ] }); Unlike … Read more