Skip to content

samsnori/tmp-metro-and-react-native

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

tmp-metro-and-react-native

Goal

This is a reproduction case aiming to identify the issue where metro.config.js with nodeModulesPaths fails to find my module. After reviewing several posts (this and this) it appears feasible to utilize React Native with npm packages located in directories separate from the project.

For instance, you can have a package located at: /home/sam/my-package and utilize it in a project stored at /home/sam/projects/my-app/. This is achieved by configuring the metro.config.js file.

The Issue

However, I'm encountering difficulties making this setup work, and the reason is unclear to me. I've followed the steps outlined here, such as adding the module path for my-package to the nodeModulesPaths in metro.config.js. To diagnose the problem, I've created this repro case. In app/metro.config.js, I've added a path to my-package, which I intend to use in app/App.jsx. However, this results in an error:

error: Error: Unable to resolve module my-package from /home/....: my-package could not be found within the project or in these directories:
  node_modules
  ../my-package

To Reproduce

git clone https://github.com/samsnori/tmp-metro-and-react-native.git
cd tmp-metro-and-react-native
cd app

npm install
npm start

About

Repro case where metro.config.js with nodeModulesPaths is not finding module.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published