React-native: Unable to resolve module path from ...

Created on 8 Mar 2016  路  12Comments  路  Source: facebook/react-native

Hey. I get the famous red error box with the message "Unable to resolve module path from ... /_/_/node_modules/amdefine/amdefine.js". The path stated here though exists and I wonder what the issue could be. Until now I followed the described steps of the error:
1) upgrading to latest RN
2) watchman watch-del-all
2) rm -rf $TMPDIR/react-*
3) npm start -- --reset-cache
3) restart the packager

Any idea what else the issue could be?
Thanks a lot!

Ran Commands Locked

Most helpful comment

If anyone have the same error: actually the missing module is named "path", required by amdefine. So in the sentence "Unable to resolve module path from ...", one must read as "Unable to resolve module $MODULE_THAT_HAPPENS_TO_BE_NAMED_PATH from ...".

The package amdefine require the "path" module provided by node.js. But in react-native's context, this native module does not exist. So as a simple workaround, just install a drop-in replacement:

npm install --save path

All 12 comments

Maybe I'll ask a very silly question, but are you sure you have amdefine installed?

Yes, certainly - the path exists but the difference is that it was installed (and is required) via a dependency. Anyway what I wonder about is that the file path of the actual error message exist so there must be a check for a different file. Can you point out any potential checks that I can debug?

was installed (and is required) via a dependency

What is the dependency name?

if you filename is A.js , but you use import {some} from './a' it will be error

@facebook-github-bot stack-overflow

Hey @jaulz and thanks for posting this! @mkonicek tells me this issue looks like a question that would be best asked on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only. Will close this as this is really a question that should be asked on SO.

If anyone have the same error: actually the missing module is named "path", required by amdefine. So in the sentence "Unable to resolve module path from ...", one must read as "Unable to resolve module $MODULE_THAT_HAPPENS_TO_BE_NAMED_PATH from ...".

The package amdefine require the "path" module provided by node.js. But in react-native's context, this native module does not exist. So as a simple workaround, just install a drop-in replacement:

npm install --save path

@laurent-descrivan Thank you very much for the post.

@laurent-descrivan That little workaround it could solve you, but to me, first it was "path", then "fs", and it stays there (even If I do npm i --save fs it gives the module error)

@FMGordillo me the same! any solutions?

This is like trying to use node specific modules in the browser.

React Native JS != Browser JS != Node JS

When you are looking for a package you need to make sure it will work in your environment. While most packages that work in the browser will work in react native, node specific packages will not work in react native. So you really wanna pay attention for which JS envrionment a package is.

Hello, I find the solution for my problem. I am using https://github.com/mcnamee/react-native-starter-app, so when I commited my app to repo, it ignored .babelrc file, so the babel-dot-env module broke fs , I don't know exacly why. but no its Okay.

Was this page helpful?
0 / 5 - 0 ratings