2
import React from 'react'
import { observer } from 'mobx-react'; //Cause of Error

export default observer(App); //At the bottom of the code

the only line causing an error is import { observer } from 'mobx-react'; and gives my the following error

./node_modules/mobx-react-lite/es/utils/assertEnvironment.js
Attempted import error: 'makeObservable' is not exported from 'mobx'.
Mechanic
  • 5,015
  • 4
  • 15
  • 38
aneuroo
  • 77
  • 1
  • 8

2 Answers2

2

update mobx to last version and try again

1

While building my project, I encountered an error in my console similar to the following:

Failed to compile.
./somefile/some.file.js
Attempted import error: 'makeObservable' is not exported from 'mobx'.

This issue arises because versions 5 and below of the mobx library do not include an exported makeObservable member in their interface. You can verify this by checking your yarn.lock or package-lock.json file for the installed version. To resolve this issue, update the mobx library to the latest version. I am currently using the following versions:

"mobx": "6.8.0",
"mobx-react": "7.6.0",

Updating to these versions should resolve the issue.

Nakul Gawande
  • 456
  • 4
  • 4