How to use npm instead of yarn with the “expo init” cli (react native tip)
tl:dr — run expo init ‘project_name’ --npm
This guide assumes that you have already installed the expo cli globally. You can find a comprehensive guide on how to set that up on the official expo documentation
You might have at one point installed yarn on your machine to follow along with a coding tutorial or as a requirement on a past project you were working on. You now have both yarn and npm installed on your machine and you don't want to uninstall either of them(for whatever technical 'it depends' reason). By default expo cli falls back to yarn when it is available but due to preference you want to use npm.
The solution in this case is to use the
--npm flag when initializing a new expo react native project. The cli hints at what you should use but doesn't explicitly describe where it should be used. This is done by typing
expo init project-name with the
expo init unicornfinder --npm
expo init 'project-name' --npm statement, you can now initialize your application with npm as its default package manager. Remember that you will have to run the
expo init command with the
--npm flag everytime you want a new project to use npm as your preferred package manager.
Thanks for reading and Happy coding!!