7
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Expoのエラー「Invariant Violation: Tried to register two views with the same name RNCSafeAreaProvider」

Last updated at Posted at 2020-07-17

React Native (Expo)のアプリを開発していたら急に以下のエラーがiOSのみで発生.どうにか解決できたのでその方法を残しておきます.

現象

  • iOSのみで発生するエラー,起動時にクラッシュ

  • Androidはなぜか動く

エラー内容

Invariant Violation: Tried to register two views with the same name RNCSafeAreaProvider

invariant
    browser.js:38:14
exports.register
    ReactNativeViewConfigRegistry.js:86:11
<unknown>
    AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:141749:57
loadModuleImplementation
    require.js:321:11
<unknown>
    AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:141605:66
loadModuleImplementation
    require.js:321:11
<unknown>
    AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:141534:36
loadModuleImplementation
    require.js:321:11
<unknown>
    AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:141093:47
loadModuleImplementation
    require.js:321:11
<unknown>
    AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:141004:53
loadModuleImplementation
    require.js:321:11
<unknown>
    AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:140287:64
loadModuleImplementation
    require.js:321:11
<unknown>
    AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:133988:26
loadModuleImplementation
    require.js:321:11
<global>
    AppEntry.js:3
loadModuleImplementation
    require.js:321:11
guardedLoadModule
    require.js:201:44
global code
    AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:202577:3

解決

手段

  • 普通に動作する部分までcommitを遡り,package-lock.jsonを比較

原因

  • "react-native-safe-area-context"がv3.1.1でインストールされていた

  • expoがv38.0.8のとき,react-native-safe-area-contextはv3.0.7に互換性がある.しかし,package.jsonで^3.0.7もしくは~3.0.7と指定していると,v3.1.1がインストールされてしまいエラーが発生していた.

解決方法

  • packageをクリーンアップ
rm -rf node_modules package-loc.json
  • バージョンを指定

package.json

"react-native-safe-area-context": "3.0.7"

バージョン指定

  • yarnを使っているならresolutionsで指定

  • ちゃんとバージョンを指定したければ以下のサイトを参照

package.json のチルダ(~) とキャレット(^) - Qiita

7
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?