Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

fix: resolve and import metro-config from the project #2048

Merged
merged 2 commits into from
Apr 30, 2020

Conversation

fson
Copy link
Contributor

@fson fson commented Apr 29, 2020

Fixes "Error: Cannot find module 'metro-config'" when running

EXPO_USE_DEV_SERVER=true expo start

Fixes "Error: Cannot find module 'metro-config'" when running
EXPO_USE_DEV_SERVER=true expo start
@fson fson requested a review from EvanBacon April 29, 2020 22:13
@fson
Copy link
Contributor Author

fson commented Apr 29, 2020

I initially missed this because @expo/metro-config had metro-config as a devDependency.

@@ -96,5 +96,7 @@ export async function loadAsync(
if (reporter) {
defaultConfig = { ...defaultConfig, reporter };
}
const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });
const { loadConfig } = require(resolveModule('metro-config', projectRoot, exp));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be useful to get the path with projectHasModule('metro-config', projectRoot, exp) and if the returned path is nullish then throw an error informing the user how to install the package.

Copy link
Contributor

@EvanBacon EvanBacon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fson fson merged commit 5c695c9 into master Apr 30, 2020
@fson fson deleted the @fson/metro-config-import branch April 30, 2020 10:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants