Closed elliotdickison closed 1 year ago
Here's my temporary workaround (wrapping the config logic that searches through dependencies in a try/catch):
diff --git a/build/loadConfig.js b/build/loadConfig.js
index fcf5068470e8ec71c2fbd8c8e5eb701679107acb..798972f2b8088ab588cea7ba4bcb61a8055b2c4c 100644
--- a/build/loadConfig.js
+++ b/build/loadConfig.js
@@ -90,22 +90,29 @@ function loadConfig(projectRoot = (0, _cliTools().findProjectRoot)()) {
};
const finalConfig = Array.from(new Set([...Object.keys(userConfig.dependencies), ...(0, _findDependencies.default)(projectRoot)])).reduce((acc, dependencyName) => {
const localDependencyRoot = userConfig.dependencies[dependencyName] && userConfig.dependencies[dependencyName].root;
- let root = localDependencyRoot || (0, _cliTools().resolveNodeModuleDir)(projectRoot, dependencyName);
- let config = (0, _readConfigFromDisk.readDependencyConfigFromDisk)(root, dependencyName);
- const isPlatform = Object.keys(config.platforms).length > 0;
- return (0, _assign.default)({}, acc, {
- dependencies: (0, _assign.default)({}, acc.dependencies, {
- get [dependencyName]() {
- return getDependencyConfig(root, dependencyName, finalConfig, config, userConfig, isPlatform);
- }
-
- }),
- commands: [...acc.commands, ...config.commands],
- platforms: { ...acc.platforms,
- ...config.platforms
- },
- healthChecks: [...acc.healthChecks, ...config.healthChecks]
- });
+ // PATCH: Wrap this logic in a try/catch so that the CLI doesn't fail in
+ // production mode when dev dependencies aren't installed. See:
+ // https://github.com/react-native-community/cli/issues/1750
+ try {
+ let root = localDependencyRoot || (0, _cliTools().resolveNodeModuleDir)(projectRoot, dependencyName);
+ let config = (0, _readConfigFromDisk.readDependencyConfigFromDisk)(root, dependencyName);
+ const isPlatform = Object.keys(config.platforms).length > 0;
+ return (0, _assign.default)({}, acc, {
+ dependencies: (0, _assign.default)({}, acc.dependencies, {
+ get [dependencyName]() {
+ return getDependencyConfig(root, dependencyName, finalConfig, config, userConfig, isPlatform);
+ }
+
+ }),
+ commands: [...acc.commands, ...config.commands],
+ platforms: { ...acc.platforms,
+ ...config.platforms
+ },
+ healthChecks: [...acc.healthChecks, ...config.healthChecks]
+ });
+ } catch (_error) {
+ return acc
+ }
}, initialConfig);
return finalConfig;
}
Hi @elliotdickison, thanks for reporting a bug. Gonna take a look on this one
Environment
Description
The CLI fails with the error
Failed to load configuration of your project.
if any development dependencies listed inpackage.json
are not installed (even if those dependencies are not actually referenced anywhere in the project).Potentially related issues: #1169 #1681
Reproducible Demo
npx create-expo-app test-rn-app
cd ./test-rn-app
npm install left-pad --save-dev
npm install --production
npx react-native info
(fails)