"npm install" failed due to missing react 15.x.x

#1

I’m trying to use expo sdk 16.0.0, and I use npm create-react-native-app to create a test app. I followed https://blog.expo.io/expo-sdk-v16-0-0-is-now-available-2151d555a580 to update dependencies, here are my config files.

app.json
{
“expo”: {
“sdkVersion”: “16.0.0”,
“packagerOpts”: {
“assetExts”: [“ttf”]
}
}
}

package.json
{
“name”: “rainier”,
“version”: “0.1.0”,
“private”: true,
“devDependencies”: {
“react-native-scripts”: “0.0.29”,
“jest-expo”: “~0.4.0”,
“react-test-renderer”: “16.0.0-alpha.6”
},
“main”: “./node_modules/react-native-scripts/build/bin/crna-entry.js”,
“scripts”: {
“start”: “react-native-scripts start”,
“eject”: “react-native-scripts eject”,
“android”: “react-native-scripts android”,
“ios”: “react-native-scripts ios”,
“test”: “node node_modules/jest/bin/jest.js --watch”
},
“jest”: {
“preset”: “jest-expo”
},
“dependencies”: {
“babel-preset-react-native-stage-0”: “^1.0.1”,
“expo”: “^16.0.0”,
“react”: “16.0.0-alpha.6”,
“react-native”: “https://github.com/expo/react-native/archive/sdk-16.0.0.tar.gz
}
}

“npm install” gives me following errors
npm WARN lottie-react-native@1.1.1 requires a peer of react@>=15.3.1 but none was installed.
npm WARN react-native-maps@0.12.2 requires a peer of react@>=15.4.0 but none was installed.
npm WARN react-native-svg@4.4.1 requires a peer of react@>=15.4.0 but none was installed.

It looks like expo sdk 16 uses some old react native modules that requires react 15. How can I fix this? Thanks.

#2

I’m not sure if this is the problem, but sometimes npm or yarn caches stuff and causes those sorts of warns to show for me when I make a bunch of npm updates. Maybe try deleting your node_modules, then clearing the cache(npm cache clean), then npm installing again.

#3

I did clean npm cache and delete node_modules but it doesn’t fix the issue.

#4

create react native app already targets sdk 16

#5

I did a yarn install instead and only got one warning this time. Not sure how to fix it though.

warning
"react-native-gesture-handler@1.0.0-alpha.17" has incorrect peer dependency “react@>= 16.0.0”.

but got these with npm

npm WARN lottie-react-native@1.1.1 requires a peer of react@>=15.3.1 but none was installed.
npm WARN react-native-branch@2.0.0-beta.3 requires a peer of react@>=15.4.0 but none was installed.
npm WARN react-native-gesture-handler@1.0.0-alpha.17 requires a peer of react@>= 16.0.0 but none was installed.
npm WARN eslint-plugin-react-native@3.1.0 requires a peer of eslint@^3.17.0 || ^4.0.0 but none was installed.