Home > Mobile >  how do i add yarn package to react native project installed with npm?
how do i add yarn package to react native project installed with npm?

Time:10-22

Note: Do guide me if something is missing.

So, I wanted to install a package from https://rnfirebase.io/auth/usage, but I have an npm project. The command on the website has only for yarn. I don't want to add yarn to project because (Is there any harm in using NPM and Yarn in the same project?) it states that it is not recommended.

So, then how do I install it with npm?

CodePudding user response:

You have to use yarn, or you can look for a package that has the functions that you are looking for using npm

CodePudding user response:

You can install it with npm just fine, don't worry. They are all package managers installing npm packages from the same repository. There is no difference in what you are installing or how they are installed. You can get different node_module structures, but for yarn you need config for that.

Yes its not recommended because it generates different lockfiles that will dictate different structures and versions in your node_modules folder. You want multiples devs to have the same "experience". However, lots of JS frameworks will come pre-configured with yarn, like React Native and you just end up having two lockfiles. One for npm and one for yarn. There is no harm in deleting the yarn file and keeping the package-lock. If you delete both, a new lockfile for the package manager you are using will be generated on npm i | yarn i | pnpm anyway.

To install it with npm just use npm i <PACKAGE_NAME> so npm i @react-native-firebase/app.

Here is the npm repo page for that package, https://www.npmjs.com/package/@react-native-firebase/app, notice the install command is npm! Only reason firebase devs only mention yarn is because they are hipsters ;)

  • Related