mobxjs / mobx-react

React bindings for MobX
https://mobx.js.org/react-integration.html
MIT License
4.85k stars 350 forks source link

Can't resolve 'mobx' in '.../node_modules/mobx-react' after install in a fresh react app #506

Closed jcollum-nike closed 6 years ago

jcollum-nike commented 6 years ago

Module not found: Can't resolve 'mobx' in '/Users/jco/my-app/node_modules/mobx-react'

Steps:

  1. follow guide here: https://github.com/facebook/create-react-app/blob/master/README.md#getting-started

  2. yarn start

  3. confirm app works (it does)

  4. yarn add mobx-react

  5. add import { observer } from 'mobx-react'; to src/App.js

Result:

Failed to compile
./node_modules/mobx-react/index.module.js
Module not found: Can't resolve 'mobx' in '/Users/jcol53/learning/my-app/node_modules/mobx-react'
This error occurred during the build time and cannot be dismissed.

This could be a react issue but the relevant issue is locked.

kikoseijo commented 6 years ago

Add it.

yarn add mobx-react mobx-persist mobx mobx-react-form validatorjs valid-url

jcollum-nike commented 6 years ago

That yarn add seems to have fixed it. Is this a bug?

I didn't add it to the react repo because I was able to successfully add/import Enzyme in the same file, which tells me it's a mobx-react problem.

mweststrate commented 6 years ago

No, mobx is a peer dependency. It is like using react-dom without react

Op vr 15 jun. 2018 23:58 schreef jcollum-nike notifications@github.com:

That yarn add seems to have fixed it. Is this a bug?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx-react/issues/506#issuecomment-397752748, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvGhKlAHWSgVbBfO-VFvz0GMBZnKSOCks5t9C32gaJpZM4UqMEY .

jcollum commented 6 years ago

Yeah I see. I missed that warning because it was so mild. I made a new issue in Yarn https://github.com/yarnpkg/yarn/issues/6011