babel-loader jsx SyntaxError: Unexpected token [duplicate]

Add “babel-preset-react” npm install babel-preset-react and add “presets” option to babel-loader in your webpack.config.js (or you can add it to your .babelrc or package.js: http://babeljs.io/docs/usage/babelrc/) Here is an example webpack.config.js: { test: /\.jsx?$/, // Match both .js and .jsx files exclude: /node_modules/, loader: “babel”, query: { presets:[‘react’] } } Recently Babel 6 was released and … Read more

Getting Unexpected Token Export

Updated for 2022 You are using EcmaScript Module (ESM or ‘ES6 Modules’) syntax but your environment does not support it. NodeJS versions prior to v14.13.0 do not support ESM (export keyword syntax) and use CommonJS Modules (module.exports property syntax). NodeJS v14.13.0 and newer supports ESM but it must be enabled first. Solutions: If you are … Read more

Call async/await functions in parallel

You can await on Promise.all(): await Promise.all([someCall(), anotherCall()]); To store the results: let [someResult, anotherResult] = await Promise.all([someCall(), anotherCall()]); Note that Promise.all fails fast, which means that as soon as one of the promises supplied to it rejects, then the entire thing rejects. const happy = (v, ms) => new Promise((resolve) => setTimeout(() => resolve(v), … Read more

Babel 6 regeneratorRuntime is not defined

babel-polyfill (deprecated as of Babel 7.4) is required. You must also install it in order to get async/await working. npm i -D babel-core babel-polyfill babel-preset-es2015 babel-preset-stage-0 babel-loader package.json “devDependencies”: { “babel-core”: “^6.0.20”, “babel-polyfill”: “^6.0.16”, “babel-preset-es2015”: “^6.0.15”, “babel-preset-stage-0”: “^6.0.15” } .babelrc { “presets”: [ “es2015”, “stage-0” ] } .js with async/await (sample code) “use strict”; export … Read more

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 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)