react-native-vector-icons: Error: Unable to resolve module `@react-native-community/toolbar-android`

After upgrading to the new version 6.7.0, bundling fails at:

error: Error: Unable to resolve module `@react-native-community/toolbar-android` from `node_modules\react-native-vector-icons\lib\toolbar-android.js`: @react-native-community/toolbar-android could not be found within the project.   

Installing the @react-native-community/toolbar-android package solves the error, but I’m not sure if that’s the wanted behaviour. It should be mentioned in README at least.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 56
  • Comments: 58 (5 by maintainers)

Commits related to this issue

Most upvoted comments

For me: I remove the ‘^’ from : -“react-native-vector-icons”: “^6.6.0” -> “react-native-vector-icons”: “6.6.0” rm -rf node_modules npm install

You’re getting those errors because the toolbar module is still in metro’s cache.

To fix this, run:

rm -rf node_modules/
rm -rf package.lock.json
npm i
react-native start --reset-cache

Hey, try out 7.0.0 where Icon.AndroidToolbar has been removed.

for me even after installing yarn add @react-native-community/toolbar-android it does not work

@oblador I get the following error after upgrading to 7.0.0:

error: Error: Unable to resolve module `./toolbar-android` from `node_modules/react-native-vector-icons/lib/create-icon-set.js`: 

None of these files exist:
  * node_modules/react-native-vector-icons/lib/toolbar-android(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  * node_modules/react-native-vector-icons/lib/toolbar-android/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

@Johan-dutoit Why would a Vector-Icon Library import an Android Toolbar Widget?

@Johan-dutoit Why would a Vector-Icon Library import an Android Toolbar Widget?

Great question…

@brunodias28 Yes, that would be downgrading to the latest working version. This issue is specifically for a bug in 6.7.0

Just Import it direct from react native it solves my problem

node_modules\react-native-vector-icons\lib\toolbar-android.js

import { ToolbarAndroid } from 'react-native';

for me even after installing yarn add @react-native-community/toolbar-android it does not work

This worked for me

@xxczaki @hudaprs try to --reset-cache your metro server

You’re getting those errors because the toolbar module is still in metro’s cache.

To fix this, run:

rm -rf node_modules/
rm -rf package.lock.json
npm i
react-native start --reset-cache

thank you.

Downgrade to 6.6.0 solved my problem

@amerllica

You don’t need to install toolbar-android. The version 7.0.0 fixes the problem.

As mention above, you may need to clear some caches, but it is working fine on Android and iOS without the dependency

Same problem here after upgrading to 7.0.0

@oblador I get the following error after upgrading to 7.0.0:

error: Error: Unable to resolve module `./toolbar-android` from `node_modules/react-native-vector-icons/lib/create-icon-set.js`: 

None of these files exist:
  * node_modules/react-native-vector-icons/lib/toolbar-android(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  * node_modules/react-native-vector-icons/lib/toolbar-android/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

I’ve solved this issue doing this:

  1. delete node_modules

rm -rf node_modules/

  1. remove version 6.7.0 of react-native-vector-icons in the package json changes to version 7.0.0 like this:

“react-native-vector-icons”: “^7.0.0”

  1. install node_modules

npm i

  1. yarn add @react-native-community/toolbar-android

  2. Run like this npm start:

npm start -- --reset-cache

Dear @RBalconi, please read whole the conversation. my solution can help you now. but a few later I will update the SO post.

I managed to solve it, redid the method, upgraded to 7.0.0 and cleared the cache with:

npm start -- --reset-cache

Thank you

You’re getting those errors because the toolbar module is still in metro’s cache.

To fix this, run:

rm -rf node_modules/
rm -rf package.lock.json
npm i
react-native start --reset-cache

if this problem still exist just please go to package.json file and remove ^ from react-native-vector-icons like "react-native-vector-icons": "6.6.0" and then folow the above steps.

The solution of @amerllica is good. Be carefull that another library do not use also react-native-vector-icons. For me it was native-base that used the version 6.7.0. You can force the version with this tips in the package.json:

 "resolutions": {
    "native-base/react-native-vector-icons": "6.6.0"
  },

@xxczaki @hudaprs try to --reset-cache your metro server

Amazing, get back to work again, Thanks!

For my case, the project was using @native-base and it brings the latest version of @native-base/react-native-vector-icons … and at the same time forced to install dependency @react-native-community/toolbar-android solution when using native-base:

add resolutions on package.json:

	"resolutions": {
		...,
		"react-native-gesture-handler": "1.2.1",
		"react-native-vector-icons": "6.6.0"
	},

for me even after installing yarn add @react-native-community/toolbar-android it does not work

it’s working for me

Dear @john1jan, I install toolbar-android by using this command:

yarn add @react-native-community/toolbar-android

and everything gets back on track.

see complete solution on Stack Overflow

it works, thank you

yarn add @react-native-community/toolbar-android this worked for me using react-native 0.61.0 and react-native-vector-iicons 7.0.0

Dear @john1jan, I install toolbar-android by using this command:

yarn add @react-native-community/toolbar-android

and everything gets back on track.

see complete solution on Stack Overflow

LOL Works for me!!! Thanks man

This is what worked for me…

  1. delete entire project directory
  2. clone a new copy
  3. yarn
  4. npx pod-install
  5. yarn ios

and I was back up and running.

@amerllica as already mentioned multiple times, you need to clear your cache. see my comment above.

@LuigiMaestrelli, I installed version 7.0.0 and the problem still existed. For now, the right solution is installing toolbar-android.