Are yarn and npm interchangeable in practice?
<p>I have a project with a package.json file and an install bash script that, among other steps, runs <code>npm install</code>.</p>

<p>I'm thinking of updating the script so that it runs <code>yarn install</code> if <a href="https://yarnpkg.com/" rel="noreferrer">yarn</a> is available (to take advantage of yarn's caching, lockfile, etc), and falls back to <code>npm install</code> otherwise. As far as I can tell, all the packages seem to install and work ok either way.</p>

<p>Are <code>yarn</code> and <code>npm</code> interchangeable enough for this to be a viable approach, though? Or are there potential issues that this could lead to? Are we meant to just pick one, or is yarn interchangeable with npm in practice?</p>

<p>(nb. I've read this <a href="https://stackoverflow.com/questions/40309048/yarn-npm-multiple-devs">closely related question</a>, but I'm asking this as a separate question because it's about explicitly supporting both yarn and npm install processes in a project)</p>