Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found if installed in a parent folder package.json #13979

Closed
SandroMachado opened this issue May 15, 2017 · 1 comment
Closed

Module not found if installed in a parent folder package.json #13979

SandroMachado opened this issue May 15, 2017 · 1 comment
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@SandroMachado
Copy link
Contributor

SandroMachado commented May 15, 2017

Description

I have a project with more than one package and I want to be able to install a set of dependencies for all the packages. For that I have defined the following project structure:

root
  mainfolder
    package.json
    node_modules
    packages
      react-native-app
        package.json
        node_modules
        index.js
      ....

I want to do something like add lodash in the mainfolder package.json and I want to be able to access to it in index.js of the react-native-app without add it to the package.json inside the react-native-app folder. AFAIK it should work, and for the error log, the packager search in those directories, but it does not find them.

I am getting the following error in the app screen:

Unable to resolve module `lodash` from `/Users/xxx/Desktop/xxx/xxx-app/packages/mobile/src/index.js`: Module does not exist in the module map or in these directories:
  /Users/xxx/Desktop/xxx/xxx-app/packages/mobile/node_modules
,   /Users/xxx/Desktop/xxx/xxx-app/node_modules

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.
......

I have confirmed that the module is installed in the parent node_modules folder but the packager is not able to find it. Any thoughts on how to fix this? Am I missing something?

Additional Information

  • React Native version: 0.44.0
  • Platform: both
  • Development Operating System: macOS
@skevy
Copy link
Contributor

skevy commented Jun 8, 2017

Hi there!

The packager no longer lives in this repo. It now lives in https://github.com/facebook/metro-bundler. The reasoning for the split is explained here: #13976.

If you're still interested in pursuing this issue, please open an issue on that repo! :)

Thanks!
-Adam

@skevy skevy closed this as completed Jun 8, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Jun 8, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants