Reputation: 85
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'.
Upvotes: 2
Views: 3634
Reputation: 536
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.
Upvotes: 1