Attempted import error: 'default' is not exported from '../assertThisInitialized/_index.mjs'

Viewed 1597

Suddenly my react is application throwing this error

./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
Attempted import error: 'default' is not exported from '../assertThisInitialized/_index.mjs'.

Earlier it was working but today it is throwing error

package.json

"react": "^16.8.6",      
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.2",
"babel-jest": "^24.8.0",
"babel-loader": "^7",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-runtime": "^6.26.0",
"webpack": "^4.35.3",
3 Answers

Try specifying explicit versions of Babel and webpack

Use an older version of Babel Runtime 7.12.13 or older

Work around . double click on the error file path to open the file. ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js file and remove '/index.mjs' from the path .

export {default} from '../assertThisInitialized'

I got the solution. Add "@babel/runtime@7.5.0" under resolutions in package.json to force babel-preset-react-app to use @babel/runtime@7.5.0

 "resolutions": {
    "**/@babel/runtime": "7.5.0"
  },
Related