diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d092b8448..67aaba689f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ This is the log of notable changes to Expo CLI and related packages. ### 🐛 Bug fixes +- Make `expo install` pass through to npm or yarn directly when running it in a bare React Native app without the expo package installed + ## [Mon, 28 Sep 2020 12:02:49 -0700](https://github.com/expo/expo-cli/commit/19e206bdc3973aa5263a11999c9624ef3590b00d) ### 🛠 Breaking changes diff --git a/packages/expo-cli/src/commands/install.ts b/packages/expo-cli/src/commands/install.ts index d0f8f625eb..1b786dc53e 100644 --- a/packages/expo-cli/src/commands/install.ts +++ b/packages/expo-cli/src/commands/install.ts @@ -35,21 +35,33 @@ async function installAsync(packages: string[], options: PackageManager.CreateFo log, }); - // This ends up being confusing for people. If they're using expo install, - // let's just install the deps such that they work in the client even if - // it's a bare project. + const { exp, pkg } = ConfigUtils.getConfig(projectRoot, { skipSDKVersionRequirement: true }); + + // If using `expo install` in a project without the expo package even listed + // in package.json, just fall through to npm/yarn. // - // if (workflow === 'bare') { - // return await packageManager.addAsync(...packages); - // } + if (!pkg.dependencies['expo']) { + return await packageManager.addAsync(...packages); + } + + if (!exp.sdkVersion) { + log.addNewLineIfNone(); + log.error( + `The ${log.chalk.bold(`expo`)} package was found in your ${log.chalk.bold( + `package.json` + )} but we couldn't resolve the Expo SDK version. Run ${log.chalk.bold( + `${packageManager.name.toLowerCase()} install` + )} and then try this command again.` + ); + log.newLine(); + process.exit(1); + return; + } - const { exp } = ConfigUtils.getConfig(projectRoot); if (!Versions.gteSdkVersion(exp, '33.0.0')) { log.addNewLineIfNone(); log.error( - `${log.chalk.bold( - `expo install` - )} is only available for managed apps using Expo SDK version 33 or higher.` + `${log.chalk.bold(`expo install`)} is only available for Expo SDK version 33 or higher.` ); log.newLine(); log(log.chalk.cyan(`Current version: ${log.chalk.bold(exp.sdkVersion)}`));