【发布时间】:2021-01-24 03:16:27
【问题描述】:
import React from 'react'
import { observer } from 'mobx-react'; //Cause of Error
export default observer(App); //At the bottom of the code
导致错误的唯一行是 import { observer } from 'mobx-react'; 并给出以下错误
./node_modules/mobx-react-lite/es/utils/assertEnvironment.js
Attempted import error: 'makeObservable' is not exported from 'mobx'.
【问题讨论】:
-
修复它.. 没有在项目中导入 mobx npm install mobx --save
-
你能详细说明你到底做了什么...我面临同样的问题...我在 package.json 中有 mobx
-
npm install mobx --save(在你的 react 项目文件位置的 cmd 中)
-
同时安装 mobx-react 和 mobx-react-lite
标签: reactjs mobx mobx-react-lite