NPM or Yarn? What is the standard practice of starting React Native projects and managing packages?

Viewed 3820

When starting a new React Native project as below it's set up with yarn as it creates a yarn.lock file.

react-native init myProjectName

At the same time, many of the common libraries assume that that NPM is being used, like for example this one:

npm install --save react-native-navigation

Now having read many debates on this online (like this one), I gather that mixing the two is generally not a good idea, and the developer should stick to one of the other.

So... I decided to use NPM as that is something I am happy, familiar and comfortable with, and I haven't seen any delta which would justify switching to Yarn in my case. (Open to be convinced otherwise.)

My Question:

  • Would it be the best practice in my case is to start a project with react-native init myProjectName, and then manually tear out the yarn parts as for example described by this Stackoverflow answer? Or is there a better way of starting React Native projects using NPM?
  • Should I just use Yarn instead, and install everything with that, because that's just the "real" React Native way, or for any other reasons?

I am looking to find out what the best practice is and stick to it from now on. If possible, I'd rather not burn more gas thinking about package management in the future.

1 Answers

Each has their own respective benefits.

Yarn: Benefits

  • Considered faster than NPM
  • Easy to use/stable
  • Not too much of a departure from NPM

Yarn: Drawbacks

  • Doesn't work with node v5 or older.

  • Has had issues when installing/compiling native modules. Though I believe there are more recent updates/workarounds.

Related